I have 2 models in different namespace.
class Admin::Membership < ActiveRecord::Base
has_many :authorization_roles
end
class AuthorizationRole < ActiveRecord::Base
belongs_to :membership
end
The Membership model is in different folder with AuthorizationRole model (I don’t know what is called)
When run Admin::Membership.find(:all), the data from AuthorizationRole model is not included. I’ve create membership_id field on authorization_roles table, but I still can’t get both models related. Is something wrong in this code? Sorry if I’m missing something basic here.
I’ve never used namespaced models and I don’t think you need to… but maybe you’ll have to specify the class name in AuthorizationRole, something like:
UPDATE:
Assuming you have:
You have added an integer column called membership_id to authorization_roles and you’ve run the migrations. Now you should be able to create authorization_roles like this
@membership.authorization_roles.create( ... )and fetch them@membership.authorization_roles