Forum: Ruby on Rails pls,explain about search action

Announcement (2017-05-07): www.ruby-forum.com is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see rubyonrails.org/community and ruby-lang.org/en/community for other Rails- und Ruby-related community platforms.
Thiti P. (Guest)
on 2009-03-30 07:08
(Received via mailing list)
Hello,
i want create web page for searching items in database. i try to run
code to find items in script/console it's work.but i have problem
about show results after find items in database finish. pls, explain
me what next step that i can do.
def search
    @title = "Search"
    if params[:q] #receives query from user
      initial= params[:q]
      seqs = Seq.find(:all, #find item in Seq database by finding the
org_name
                  :conditions => "org_name LIKE '#{initial}%'",
                  :order => "seq_id, org_name")
      redirect_to :controller => "result", :action => "index" #after
searching go to index page for show results
     end
end
#######but  i have problem about show results pls help me how can
create page to show result ?
thank you very much -__-
Siddick E. (Guest)
on 2009-03-30 10:32
Thiti Panya wrote:
> Hello,
> i want create web page for searching items in database. i try to run
> code to find items in script/console it's work.but i have problem
> about show results after find items in database finish. pls, explain
> me what next step that i can do.
> def search
>     @title = "Search"
>     if params[:q] #receives query from user
>       initial= params[:q]
>       seqs = Seq.find(:all, #find item in Seq database by finding the
> org_name
>                   :conditions => "org_name LIKE '#{initial}%'",
>                   :order => "seq_id, org_name")
>       redirect_to :controller => "result", :action => "index" #after
> searching go to index page for show results

I think you wrongly used redirect_to. Use the render method.
Maintain the Query result in a Instance Variable.

>      end
> end
> #######but  i have problem about show results pls help me how can
> create page to show result ?
> thank you very much -__-
Thiti P. (Guest)
on 2009-03-30 12:19
(Received via mailing list)
thank you very much for your help. it's work


2009/3/30 Siddick E. <removed_email_address@domain.invalid>
This topic is locked and can not be replied to.