0

In Controller

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

In View - feed_entries/index.html.erb

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

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

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

If, I click the Stared link. I am getting error like below in the browser:

undefined method `stringify_keys!' for "false":String
4
  • did you try quoting false? - i.e. :is_star => "false" Commented Mar 30, 2013 at 18:17
  • ya getting same error Commented Mar 30, 2013 at 18:29
  • you should probably include the stacktrace for your error - my guess, it is coming from inside the FeedEntry#search method? Commented Mar 30, 2013 at 18:30
  • Could you post the routes associated with the FeedEntries controller? Commented Mar 30, 2013 at 18:56

1 Answer 1

1

It looks like your FeedEntry#search method expects an argument that responds to #stringify_keys! methods, so I assume you should pass a Hash :

@search = FeedEntry.search(is_star: params[:is_star])

BTW link_to with 'controller' and 'action' options is old and verbose syntax, you should use a resourceful style:

link_to 'Stared', feed_entries_path

read more here: http://api.rubyonrails.org/classes/ActionView/Helpers/UrlHelper.html#method-i-link_to

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.