Welcome to Working With Rails


Discussion Forums

Discuss all things Ruby on Rails with perhaps the web's most vibrant group of Ruby on Rails enthusiasts.
Accessing parameter
4 Posts
Accessing parameter

I have a simple form with just one field (auto_complete_text_field)

The parameters passed to my controller method are: Parameters: {"account"=>{"locations"=>"Canton"}, "action"=>"area_search", "authenticity_token"=>"85f47cc6b00aa9b06e4e06537c1b4bea17525a0c", "method"=>"get", "controller"=>"accounts"}

I'd like to use the "locations" parameter but it doesn't seems to be working in the params call: @account = Account.find_by_name(params[:locations])

Any ideas why or how I can access it?


Take a look at the params hash you posted. The key you want, "locations", is in a hash that is nested within the params hash. That nested hash is the value keyed by "account". So, you need to do this:


you mean


Indeed I did. Markdown syntax was remarkably unhelpful in this case.

4 Posts
Login to add your message