fetch data from text_field

  • Thread starter Subhadip Chakraborty
  • Start date
S

Subhadip Chakraborty

i am new in ruby.in my program i have one .rhtml file and two
controller.
1.in search.html.erb,the code is:
<% form_tag:)action => 'search') do %>
Book_Id:
<%= text_field 'book', 'book_id' %><br>

<%= submit_tag "search" %>
<% end %>
2.in controller
class MainController < ApplicationController
def search

@book=Book.find_by_book_id(params[:book_id])


redirect_to :controller=>'search',:action=>'sv',:id=>@book

end
end


end
3.in sv.html.erb
<% for book in @books %>

<tr>

<td><%=h book.book_id %></td>
<td><%=h book.book_name %></td>
</tr>
<% end %>
4:in controller
class SearchController < ApplicationController
def sv
#@books=Book.find:)all)
@books=Book.find:)all,:conditions => ["[email protected]",
params[:book_id]])
respond_to do |format|
format.html # index.html.erb
format.xml { render :xml => @books }
end
end

end
but i am unable to fetch data fron database corresponding to book_id
which i m given through textfield..
any one can help me..
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,755
Messages
2,569,535
Members
45,007
Latest member
obedient dusk

Latest Threads

Top