【问题标题】:Rails Admin Plugin issue, for Many-to-many relationship with same modelRails Admin Plugin 问题,用于同一模型的多对多关系
【发布时间】:2011-01-16 04:35:12
【问题描述】:

我一直在关注这篇文章的第二个解决方案:Many-to-many relationship with the same model in rails?

在使用插件 Rails Admin (https://github.com/sferik/rails_admin)时

使用下面的代码,似乎特别破坏了 Rails Admin:

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

对我能做什么有什么想法吗?

更新:

这是所要求的错误:

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>

【问题讨论】:

  • "break" 不够详细。发布错误消息、堆栈跟踪等...

标签: ruby-on-rails ruby ruby-on-rails-3 ruby-on-rails-plugins


【解决方案1】:

在模型的 belongs_to 语句中,尝试将 :class_name =&gt; :Post 更改为 :class_name =&gt; 'Post'(字符串与符号)。我很确定这就是错误消息的相关内容。

【讨论】:

  • 您是天才,A++++ 将再次与您合作。说真的,谢谢,这让我很生气。
猜你喜欢
  • 1970-01-01
  • 2022-06-12
  • 1970-01-01
  • 2020-11-13
  • 2011-01-05
  • 2016-07-12
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多