Let's say you have two models: articlesand comments.
class Article < ActiveRecord::Base
has_many :comments
end
You know that you can get related comments on this article:
article = Article.first
article.comments
Is there a way to explicitly access article_id(123) in named_scope?
I need this for a complex named_scope that joins another table. Basically, named_scope will depend on being called from the associated parent to make sense ( article.comments.my_named_scopeand not Comments.my_named_scope ).
id named_scope. , article_id ... lambda { |article| ...} id "... #{article.id} ...", - article_id, others, has_many.