1

I've been following the 2nd solutions on this post: Many-to-many relationship with the same model in rails?

While using the plugin Rails Admin ( https://github.com/sferik/rails_admin )

Using the code below, specifically seems to be breaking Rails Admin:

class PostConnection < ActiveRecord::Base
  belongs_to :post_a, :class_name => :Post
  belongs_to :post_b, :class_name => :Post
end

Any ideas for what I can do?

Update:

Here is the error as requested:

NoMethodError in Rails_admin/main#index

Showing /Users/elliot/.rvm/gems/ruby-1.8.7-p299/bundler/gems/rails_admin-5713b1671e8c/app/views/rails_admin/main/index.html.erb where line #18 raised:

undefined method `match' for :Post:Symbol
Extracted source (around line #18):

15:           <tbody>
16:             <% @abstract_models.each do |abstract_model| %>
17:               <tr class="<%= cycle 'odd', 'even' %>">
18:                 <td class="modelNameRow">
19:                   <%= link_to(RailsAdmin.config(abstract_model).list.label, rails_admin_list_path(:model_name => abstract_model.to_param), :class => "show") %>
20:                 </td>
21:                 <td>
Community
  • 1
  • 1
Elliot
  • 13,580
  • 29
  • 82
  • 118

1 Answers1

6

In your model's belongs_to statements, try changing :class_name => :Post to :class_name => 'Post' (string vs symbol). I'm pretty sure that's what the error message is related to.

Peter Brown
  • 50,956
  • 18
  • 113
  • 146
  • YOU ARE A GENIUS, A++++ WOULD DO BUSINESS WITH AGAIN. Seriously though, thanks, that was killing me. – Elliot Jan 15 '11 at 20:40