KnowledgeHub
Questions
Tags
Users
Search
Alex Rivera
|
Logout
Edit Question
Title
Body
Imagine you have two defined routes: map.resources articles map.resources categories, :has_many => :articles both accessible by helpers/paths articles_path # /articles category_articles_path(1) # /category/1/articles if you visit /articles , index action from ArticlesController is executed. if you visit /category/1/articles , index action from ArticlesController is executed too. So, what is the best approach for conditionally selecting only the scoped articles depending on the calling route? #if coming from the nested resource route @articles = Articles.find_by_category_id(params[:category_id]) #else @articles = Articles.all
Tags (comma-separated)
Save Edits
Cancel