dimanche 12 avril 2015

Undefined method `stringify_keys' error using Rails 3

I am getting the following error when i set the form for searching data according to drop down value.


Error:



NoMethodError in Users#index

Showing C:/Site/searchtest/app/views/users/index.html.erb where line #4 raised:

undefined method `stringify_keys' for nil:NilClass
Extracted source (around line #4):

1: <h1>Listing users</h1>
2: <%= form_tag users_path, :method => 'get' do %>
3: <p>
4: <%= text_field_tag(:search,options_for_select([['subhrajyotipradhan@gmail.com','subhrajyotipradhan@gmail.com'],['subhrajyoti.pradhan@oditeksolutions.com','subhrajyoti.pradhan@oditeksolutions.com'],['w5call.w5rtc@gmail.com','w5call.w5rtc@gmail.com']],selected: "Select your email"), params[:search]) %>
5: <%= submit_tag "Search", :name => nil %>
6: </p>
7: <% end %>


My aim is when user will select option from drop down list the value should filtered accordingly.Please check my below code and try to help me to make it correct.


views/users/index.html.erb



<h1>Listing users</h1>
<%= form_tag users_path, :method => 'get' do %>
<p>
<%= text_field_tag(:search,options_for_select([['subhrajyotipradhan@gmail.com','subhrajyotipradhan@gmail.com'],['subhrajyoti.pradhan@oditeksolutions.com','subhrajyoti.pradhan@oditeksolutions.com'],['w5call.w5rtc@gmail.com','w5call.w5rtc@gmail.com']],selected: "Select your email"), params[:search]) %>
<%= submit_tag "Search", :name => nil %>
</p>
<% end %>
<table>
<tr>
<th>Name</th>
<th>Email</th>
<th>Content</th>
<th></th>
<th></th>
<th></th>
</tr>

<% @users.each do |user| %>
<tr>
<td><%= user.name %></td>
<td><%= user.email %></td>
<td><%= user.content %></td>
<td><%= link_to 'Show', user %></td>
<td><%= link_to 'Edit', edit_user_path(user) %></td>
<td><%= link_to 'Destroy', user, method: :delete, data: { confirm: 'Are you sure?' } %></td>
</tr>
<% end %>
</table>

<br />

<%= link_to 'New User', new_user_path %>


I want to use will_paginate gem for this functionality.Please help me.


Aucun commentaire:

Enregistrer un commentaire