Save 36% for Black Friday! Learn more

mike zenon


60 Experience
0 Lessons Completed
0 Questions Solved


Posted in How do I process request with parameters

Would you please provide me more details? Where should I add this query? I would like to display selected rows or all rows based on the parameter.

  • For GET articles?special=false, return all articles

  • For GET articles?special=true, return all articles that has "token" in the title

The followings are some source code related( That is my guess).

Thanks a lot, I am really appreciate your help!

bin/rails routes
articles GET /articles(.:format) articles#index


class ArticlesController < ApplicationController
def index
@articles = Article.all

=== app/views/articles/index.html.erb
<% @articles.each do |article| %>

<%= article.title %>
<%= article.text %>
<%= link_to 'Show', article_path(article) %>

<% end %>

Posted in How do I process request with parameters

i am new to ruby on rails, just run the examples

I just wonder if I want list all the articles with certain string in the title, how can I do it in rails?

logo Created with Sketch.

Ruby on Rails tutorials, guides, and screencasts for web developers learning Ruby, Rails, Javascript, Turbolinks, Stimulus.js, Vue.js, and more. Icons by Icons8

© 2021 GoRails, LLC. All rights reserved.