Re: Newbie: Searcing database via user form input?

Robert Walker
2008-05-28T23:14:07Z

First, it looks to me like you''re attempting to do exactly what Ryan
Bates shows in episode #37 of Railscasts:

http://railscasts.com/episodes/37

Second: What''s this?
> <% form_tag({ :action => "index", :controller =>
"users" }, :method =>
> "index") do %>
There is no "index" method in HTTP. This should be one of :get
or :post in the context of an HTML form.

On May 28, 8:24 am, Dale Cunnigham
<rails-mailing-l...-ARtvInVfO7ksV2N9l4h3zg@public.gmane.org>
wrote:
> Does anyone have a tutorial on adding new parameters to the paramaters
> list and then creating find conditions around them?
>
> I''m wondering how I can get my index page to list only the items
where
> some of the the databases fields match user form input. index.html.erb
> would be calling itself with a new parameter :searchdata
>
> So far the index.html.erb has...
>
> <% form_tag({ :action => "index", :controller =>
"users" }, :method =>
> "index") do %>
>
>
> Search Users:
<%= text_field_tag
> "searchdata", params[:searchdata] %>
>     <input id="submit" type="submit"
value="Search" />
>
>
>
> <% end %>
>
> and the users_controller index contains
>
>   def index
>     @users = User.find(:all, :conditions => "Surname LIKE ?",
> params[:searchdata])
>
>     respond_to do |format|
>       format.html # index.html.erb
>       format.xml  { render :xml => @users }
>     end
>   end
>
> So this is broken. Does anyone have a tutorial on adding new parameters
> to the paramaters list and then creating find conditions around them?
> --
> Posted viahttp://www.ruby-forum.com/.
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"Ruby on Rails: Talk" group.
To post to this group, send email to
rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org
To unsubscribe from this group, send email to
rubyonrails-talk-unsubscribe@googlegroups.com