Nuwan Indika
Nuwan Indika

Reputation: 919

search text box didn't show in view page

i need to create a search in index page this the code

<h1>Listing users</h1>
Enter Member's name:<% form_tag users_path, :method => 'get' do %>
  <p>
    <%= text_field_tag :search, params[:search] %>
    <%= submit_tag "Search", :name => nil %>
  </p>
<% end %>

in controller

  def index
    #@users = User.all
    @users= User.search(params[:search])
  end

in models

def self.search(search)
  if search
    find(:all, :conditions => ['FirstName LIKE ?', "%#{search}%"])
  else
    find(:all)
  end
end

but when run the project it doesn't display the search button and text-box how can fix this

Upvotes: 0

Views: 119

Answers (1)

Giannis
Giannis

Reputation: 813

You miss an equal sign = in your form_tag:

<%= form_tag users_path, :method => 'get' do %>

If you don't use an equal sign it just executes the code, it doesn't output it.

Upvotes: 1

Related Questions