mardi 6 décembre 2016

How can I have the names of the authors of my followed books?

In user.rb (models) I have this : has_many :followed, class_name: Following has_many :followed_books, through: :followed, source: :book

In followed.rb, I have the books' id and the users' id. In book.rb, I have also the author (with the author's name)

How can I have the names of the authors of my followed books ?

Is this correct: current_user.followed_books(:author) or just current_user.followed_books.author ?

Aucun commentaire:

Enregistrer un commentaire