please don’t shout… I’m trying to run a search query to find the Firstname in the database, basically trying to find a specific user then show that user.
What works in the console is Client.where but I can’t seem to get this to work in the controller.
irb(main):001:0>client = Client.where("name = 'Dusty'")
Client Load (0.4ms) SELECT `clients`.* FROM `clients` WHERE (name = 'Dusty')
What I have is.
A View ‘index.html.erb’:
<%= form_for :find_it do |n| %>
Name: <%= n.text_field :text, :cols => "30", :rows => "1" %></br>
<%= n.submit "Find" %>
And a Controller Method in clients_controller.rb:
def find_it
@post = Clients.all
@post = Client.where("name = ", params[:find_it])
@post = Client.find(params[:id])
end
Any assistance would be appreciated.
Your syntax is a bit off. Use hash-style conditions: