user1933313
user1933313

Reputation:

How to pass parameter through link_to?

Controller

class FeedEntriesController < ApplicationController
  def index
    @search = FeedEntry.search(params[:search])
    @feed_entries = @search.page(params[:page])
    @app_keys = AppKey.all
  end
end

My feed_entries/index.html.erb

<%= link_to "Stared", {:controller => "feed_entries", :action => "index", :search => ['is_star = ?', true] }%>

feed_entries table contain is_star:boolean attribute. So, I just want to pass the parameter is_star == true into the params[:search].

But the above code is not working. Please some one help me.

Upvotes: 0

Views: 143

Answers (1)

chrisbulmer
chrisbulmer

Reputation: 1245

Try

<%= link_to "Stared", {:controller => "feed_entries", :action => "index", :is_star => true } %?

And then you should be able to access in the controller using params[:is_star]

Upvotes: 1

Related Questions