On 9 July 2010 12:19, Zeeshan Nazim
<lists-fsXkhYbjdPsEEoCn2XhGlw@public.gmane.org>
wrote:> i am having some products in a database(mysql) n i have done the
> scaffolding and added a search.
>
> So when i search, if product found then it shud display it and if not
> found it shud redirect to create page.
>
> Here is d controller code for find i used
> ___________________
> def find
>
> @products=Product.find(:all, :conditions => ["item LIKE
> ?",params[:search_string]])
Test for @products.count == 0 here and use redirect_to to go the
appropriate action
Colin
>
> end
> ________________________
>
> and in ''find.html.erb''
> ______________________________
> <% if @products.blank? %>
> <p> EMPTY</p> # what code shud I enter here so as to redirect
to create
> page??
> <% else %>
> <% end %>
> <% for review in @reviews %>
> <h2>Listing Products for <%>
params[:search_string].capitalize%></h2>......................so on.
> ___________________________________
>
> So i want to know how to redirect to create page and where shud d code
> be written. In view or controller.? and what code shud be used to
> implement redirection.
>
> So plz som1 help.
> Nazim Zeeshan,India
> --
> Posted via http://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-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org
> To unsubscribe from this group, send email to
rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org
> For more options, visit this group at
http://groups.google.com/group/rubyonrails-talk?hl=en.
>
>
--
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-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org
To unsubscribe from this group, send email to
rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org
For more options, visit this group at
http://groups.google.com/group/rubyonrails-talk?hl=en.