In django you can create queries that span relationships
Entry.objects.filter(blog__name='Beatles Blog')
What is the rails equivalent?
Rails approach is not as clean, but it allows you to be explicit in your query. In a situation as described above, you would do
Entry.joins(:blog).where(blogs: {name: "Beatles Blog"})
This is assuming your Blog has_many :entries and your Entry belongs_to :blog
Also note that you still have access to a kind of SQL interface for this, however, you should always ensure to joins|includes|eager_load the associations that you would be querying, the way I joined the blog above.
Entry.joins(:blog).where("blogs.name = ?", "Beatles Blog")
OR using named parameters
Entry.joins(:blog).where("blogs.name = :blog_name", blog_name: "Beatles Blog")
Hope I was able to help.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With