Skip to content

Instantly share code, notes, and snippets.

@slavajacobson
Created September 7, 2013 20:53
Show Gist options
  • Save slavajacobson/b6d1feb13b3264f753a7 to your computer and use it in GitHub Desktop.
Save slavajacobson/b6d1feb13b3264f753a7 to your computer and use it in GitHub Desktop.
@movies = Movie.all(:hide.not => true)
@movies = @movies.all(:name.like => "%#{params[:title]}%", :genre.like => "%#{params[:genre]}%")
@movies = @movies.all(:year.gte => params[:from_year]) unless params[:from_year].blank?
@movies = @movies.all(:year.lte => params[:to_year]) unless params[:to_year].blank?
@movies = @movies.all(:cast.like => "%#{params[:actor]}%") unless params[:actor].blank?
@movies = @movies.all(:mpaa_rating.like => "%#{params[:mpaa_rating]}%") unless params[:mpaa_rating].blank?
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment