user4418 Published in September 20, 2018, 12:45 pm
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: