ruby on rails - How to tell ActiveRecord that a particular column belongs to a certain class and to fetch the associated class? -
i have class called conversation , column called "assigned_to" stores user.id.
i load conversations, load associated users, how can this?
my conversation class is:
class conversation < activerecord::base attr_accessible :description, :name, :assigned_to end
so need add together has_one :user
, how link :assigned_to
field? populating assigned_to field in controller, i'm trying show list user info , curious how this.
seems basic activerecord functionality, i'm relatively new , documentation doesn't seem have illustration column renamed.
i think should :
belongs_to :user, foreign_key: :assigned_to
if want more informations available options, can @ api
ruby-on-rails rails-activerecord
No comments:
Post a Comment