How I can get the same result using ActiveRecord?
SELECT categories.* FROM categories
INNER JOIN levels ON levels.id = categories.level_id where levels.description <= "Medium"
How I can get the same result using ActiveRecord?
SELECT categories.* FROM categories
INNER JOIN levels ON levels.id = categories.level_id where levels.description <= "Medium"
It's hard to be precise without more details, but it should be something like that:
Category.joins(:level).where('levels.description <= "Medium"')
I think this should also do the trick:
Category.joins(:level).where(Level.arel_table[:description].lteq('Medium'))