Search code examples
ruby-on-railsrubyruby-on-rails-3ruby-on-rails-3.1

Render a model like include


I am wondering how can i render in my header file a search model. Pretty much like an include in php, but with rails i want to render the new form into my header. I base my style of search on this video http://railscasts.com/episodes/111-advanced-search-form-revised but not to sure on how to render the code in to my header. Any help is appreciated


Solution

  • How about a partial?

    Documentation

    You can do something like this:

    <%= render "shared/search", :locals => { :search_string => @search_string } %>
    

    Which will render what is in the app/views/shared/_search.html.erb file.