Skip to content

Instantly share code, notes, and snippets.

@austinklenk
Last active December 15, 2015 02:55
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save austinklenk/c3eb95292b5c41b2f6ab to your computer and use it in GitHub Desktop.
Save austinklenk/c3eb95292b5c41b2f6ab to your computer and use it in GitHub Desktop.
# Customer Search that works
### Search Field in Customer Index Page with Table
```
<%= search_form_for @search do |f| %>
<th colspan="2"><%= f.text_field :lastName_cont, class: 'customer-search', placeholder: 'Search By Last Name' %></th>
<th><%= f.submit "Search", class: 'btn btn-info btn-block' %></th>
<% end %>
```
# Customer Index Controller Action
```
@search = Customer.search(params[:q])
@clients = @search.result.paginate(:page => params[:page]).reverse_order
```
# Customer Model for Pagination
```
WillPaginate.per_page = 20
```
**The Above works, what i am trying to do now is to create a search action for the orders which are nested under campers**
# Search Field in Camper Show
```
<%= search_form_for @search do |f| %>
<th colspan="2"><%= f.text_field :title_cont, class: 'customer-search', placeholder: 'Search By Last Name' %></th>
<th><%= f.submit "Search", class: 'btn btn-info btn-block' %></th>
<% end %>
```
# Camper Controller Show Action
```
@jobs = @camper.orders
@search = @jobs.search(params[:q])
@projects = @search.result.paginate(:page => params[:page]).reverse_order
```
# Camper Model
```
WillPaginate.per_page = 20
```
And get the error of
```undefined method `orders_path'
```
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment