Is there any way to initialize a record from session. for e.g I have a organization object and I put this in session object like
session[:organization] = organization
Now I made a custom method current_organization
(I know about devise) like
def current_organization
Organization.new(session[:organization])
end
This will return organization object. My organization
belongs_to
a team
a devise model and team
has_many :organizations
but when I call
current_team.organizations.includes?(current_organization)
in view. It is returning false even if it is included in team's organizations but doing this
current_team.organizations.reload.includes?(current_organization)
is returning true. I set the session variable with organization object before calling view where i am using above method. Is there any thing which I missed like I am not able to figure out the reason for not returning true even it is included?
Aucun commentaire:
Enregistrer un commentaire