Here are some request to a search page I have
/articles?tag=tag1&author=author1
/articles?title=title1&tag=tag1
/articles?title=title1&tag=tag1&author=author1
/articles?tag=tag1
/articles?title=title1&tag=tag1&author=author1&size=medium&is_deprecated=false&has_fotos=true
Well, what is the most efficient way to make a request to Article
model depending on a query? I wouldn't like to do something like this
@articles = Article.all
@articles = Article.find_by_tag(params[:tag]) if params[:tag]
@articles = Article.where("title like ?", params[:title]) if params[:title]
@articles = Article.find_by_author(params[:author]) if params[:author]
@articles = Article.find_by_is_deprecated(params[:is_deprecated]) if params[:is_deprecated]
#...etc
Your thoughts?