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..
controller.
1.in search.html.erb,the code is:
<% form_tag
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
@books=Book.find
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..