简体   繁体   中英

Active Admin: belongs_to giving “undefined method” Error in Rails 4

I am getting the following error when I use belongs_to relation

NoMethodError in Admin::PropertyDetailsController#index undefined method `property_types' for #AdminUser:0x00000005e59a70

Please help to resolve the issue.

I am using ActiveAdmin 0.60 with ruby 2.0.0p247 and Rails 4.

Gemfile: gem 'activeadmin', github: 'gregbell/active_admin', branch: '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. You can see the solution at

https://github.com/gregbell/active_admin/issues/2597

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM