Ruby on Rails Wednesday, January 30, 2013

On Jan 30, 2013, at 9:54 AM, Ryo Saeba wrote:

> in my console it says:
>
> "
> Started GET "/games?utf8=%E2%9C%93&search=mega&commit=Search" for
> 127.0.0.1 at 2013-01-30 15:52:18 +0100
> Processing by GamesController#index as HTML
> Parameters: {"utf8"=>"V", "search"=>"mega", "commit"=>"Search"}
> Rendered games/_no_search_yet.html.erb (0.0ms)
> Completed 200 OK in 5ms (Views: 0.0ms | ActiveRecord: 0.0ms)"
>
> what does the ":q" actually mean? I didn't name my search field, as far
> as I know, it looks like this

Yes you did. All form fields that the server knows about have a name attribute, and the Rails helper creates one. (View source in a browser to see the generated code.)

>
> <%= form_tag games_path, :method => 'get' do %>
> <p>
> <%= text_field_tag :search, params[:search] %>
> <%= submit_tag "Search", :title_german => nil %>
> </p>
> <% end %>

According to this, your field is named 'search', so you would change the parameter that the "if" depends on accordingly:

if(params[:search])
...

params[:q] would be set if the text_field_tag looked like this:

text_field_tag :q, params[:q]

Walter

>
> --
> Posted via http://www.ruby-forum.com/.
>
> --
> You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group.
> To unsubscribe from this group and stop receiving emails from it, send an email to rubyonrails-talk+unsubscribe@googlegroups.com.
> To post to this group, send email to rubyonrails-talk@googlegroups.com.
> For more options, visit https://groups.google.com/groups/opt_out.
>
>

--
You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group.
To unsubscribe from this group and stop receiving emails from it, send an email to rubyonrails-talk+unsubscribe@googlegroups.com.
To post to this group, send email to rubyonrails-talk@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.

No comments:

Post a Comment