I use rails 4 and mysql. I have two Recipe and Category models.
class Category < ApplicationRecord
validates_uniqueness_of :name, message: "deve ser único"
validates_presence_of :name, message: "can't be blank"
class Recipe < ApplicationRecord
The Recipe fields are: id, title, resume, and category_id which is the reference for category.
Category fields are: id and name
I'm trying to make a query that through the Recipe table I get as a result all the fields of the two tables. I am trying to do this with the following query:
Recipe.joins("INNER JOIN categories ON categories.id =
But the result gives me results only from the Recipe table. The result is:
Recipe id: 1, title: "ababa", resume: nil, created_at: "2018-02-07
23:16:19", updated_at: "2018-02-07 23:16:19", category_id: 9
How can I make all the data in the two tables appear?