On 16 May 2014 14:54, Walter Lee Davis <wa...@wdstudio.com> wrote:
>
> On May 16, 2014, at 9:42 AM, Fab Forestier wrote:
>
>>> Please quote the previous message in your reply so that it easier to
>>> follow the thread.  Note that this is a mailing list not a forum
>>> (though you may be accessing via a forum-like interface).
>>>
>> Sorry I will pay attention new time!
>>
>>> If the search actions do not fit well with one of the existing
>>> controller then just create one specifically for searches.  However,
>>> if the search is specifically for Articles then generally you would
>>> put search actions in the articles controller.
>>>
>>> Colin
>>
>> My search bar will appear on all my views so I think it will be better
>> if I create a new controller but how I must call it if my view is in
>> views/pages/currentop? And how my view will be associated to this
>> controller?
>
> That is down to how you structure your form tag in that view. This can be as 
> simple as a hand-coded form (no need for form_for helper here) and whatever 
> you called your controller (or however you defined your search route) will 
> determine what the actual path is. Something like this:
>
>         <form action="/search/results" method="get">
>                 <input type="search" name="q">
>         </form>
>
> Now if you have a search_controller.rb with a results method, and you made a 
> route to hook that up, you should be in business.

In addition to Walter's suggestion, I think, Fab,  you are a little
confused about the way that views and controllers work.  The form that
Walter suggests is shown in the layout and does not need to come from
any particular controller.  It is the action that is invoked when the
user requests the search that goes to a controller.  So you could just
as easily put the search action in the articles controller just by
changing the form action to articles/search and providing the
appropriate route to a search action.

Colin

-- 
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+unsubscr...@googlegroups.com.
To post to this group, send email to rubyonrails-talk@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/rubyonrails-talk/CAL%3D0gLtao07WPrvW0N3Bkv_jXfXBPL7gdRANa_87xQhfpqXBNA%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to