ruby on rails - Search result in rendered child view move to child view -


two models. category , material. category has_many materials. material belongs_to category. material has partial _list.html.erb rendering category show.html.erb everthing working find. now, have added search child view - show.html.erb:

<p id="notice"><%= notice %></p>  <p>   <h2><%= @category.category_name %></h2> </p>  <%= link_to 'edit', edit_category_path(@category) %> | <%= link_to 'back', categories_path %>  <p><%= search_form_for @q |f| %>    <%= f.label "find" %>   <%= f.search_field :sku_or_description_cont %>   <%= f.submit %> <% end %>  </p> </p> <%= render 'materials/list' %> <p></p> 

searching working fine. when click submit move me materials/index.html.erb. want stay on category view , show results of search parent view.

my categories_controler.rb show method:

# /categories/1 # /categories/1.json   def show     @q= material.where(:category_id => params[:id]).ransack(params[:q])     @materials = @q.result(distinct: true).paginate :page => params[:page]   end 

for serching/pagination using ransack (do not know if important or not). should change make work expected (search results withing categories/show view. thank you.

you should set url form, this.

<p><%= search_form_for @q, url: @category |f| %> 

Comments

Popular posts from this blog

asp.net mvc - SSO between MVCForum and Umbraco7 -

Python Tkinter keyboard using bind -

ubuntu - Selenium Node Not Connecting to Hub, Not Opening Port -