Reputation: 3115
I got a User Model with 'username' and a Posts Model with 'user_id' as foreign key. How can I display the Username in a view?
/user.rb/
has_many :posts
/posts.rb/
belongs_to :user, :class_name => "User", :foreign_key => "user_id"
I want to use it in the 'show' method
Upvotes: 0
Views: 45