Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

rails_admin has_and_belongs_to_many association #1737

Closed
r00takaspin opened this issue Sep 6, 2013 · 3 comments
Closed

rails_admin has_and_belongs_to_many association #1737

r00takaspin opened this issue Sep 6, 2013 · 3 comments

Comments

@r00takaspin
Copy link

I have has_and_belongs_to_many relation in my models. I have relation beetween models Hotels and HotelRoomsTypes

class Hotel < ActiveRecord::Base
    attr_accessible hotel_room_types_attributes    
    has_and_belongs_to_many :hotel_room_types,:class_name => "HotelRoomType"
    accepts_nested_attributes_for :hotel_room_types, :allow_destroy => true
end

class HotelRoomType < ActiveRecord::Base
  attr_accessible :name
  has_and_belongs_to_many :hotels
end

when I am trying create association in rails_admin, I see following markup:
enter image description here

after creation, rails_admin doesn't show associations to those model. Anybody solved those problem or found patch to rails_admin?

@r00takaspin
Copy link
Author

the problem is actual in rails_admin since version 0.4.2

@mibamur
Copy link

mibamur commented Feb 20, 2014

@r00takaspin is it solved now and you can close this issue?

@mshibuya
Copy link
Member

mshibuya commented Apr 3, 2014

You need to set inverse_of on both sides of has_and_belongs_to_many association.
http://stackoverflow.com/a/20224779

@mshibuya mshibuya closed this as completed Apr 3, 2014
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants