[英]Active Admin: belongs_to giving “undefined method” Error in Rails 4
I am getting the following error when I use belongs_to relation 当我使用belongs_to关系时出现以下错误
NoMethodError in Admin::PropertyDetailsController#index undefined method `property_types' for #AdminUser:0x00000005e59a70 Admin :: PropertyDetailsController#index中的NoMethodError对于#AdminUser:0x00000005e59a70未定义方法`property_types'
Please help to resolve the issue. 请帮助解决问题。
I am using ActiveAdmin 0.60 with ruby 2.0.0p247 and Rails 4. 我正在将ActiveAdmin 0.60与ruby 2.0.0p247和Rails 4一起使用。
Gemfile: gem 'activeadmin', github: 'gregbell/active_admin', branch: 'rails4' Gemfile:gem'activeadmin',github:'gregbell / active_admin',分支:'rails4'
ActiveAdmin.register PropertyDetail do
belongs_to :property_type
menu :label => "Latest Properties in the Town"
controller do
def permitted_params
params.permit(:property_detail => [:title ,:description, :image_url, :price, :land_area, :land_unit, :contact_id, :property_type_id, :purpose_id])
end
end
index do
column :title
column :description
column :image_url
column :price, :sortable => :price do |property_detail|
div :class => "price" do
number_to_currency property_detail.price
end
end
end
form :partial => "form"
end
ActiveAdmin.register PropertyType do
end
I have posted the same problem on github and it has been resolved. 我已经在github上发布了相同的问题,并且已经解决。 You can see the solution at
您可以在以下位置查看解决方案
https://github.com/gregbell/active_admin/issues/2597 https://github.com/gregbell/active_admin/issues/2597
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.