Re: Help with RoR partial views

Pardee, Roy
Wed, 20 Aug 2008 16:29:09 -0000

Your partial uses a simple form_for(@product) call.  By default that will do a
POST to the products/create action, which if it''s successful, does a
redirect to products/show/<<id for the new product>> (see the create
method in your products_controller.rb file).

My advice is to just play around w/rails for a bit & get used to its
conventions before you try to bend it to your will. ;-)

HTH,

-Roy

-----Original Message-----
From: rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org
[mailto:rubyonrails-talk@googlegroups.com] On Behalf Of CrazyMenConnected
Sent: Tuesday, August 19, 2008 3:47 PM
To: Ruby on Rails: Talk
Subject: [Rails] Re: Help with RoR partial views


I and thank you for your replies.

>>Heh--"it gives me an error" covers a lot of ground. ;-)

Yes your right, and i am sorry for that, my message was a little ambiguous.

I have changed the main_controller.rb  and i''ve added the instance
variable has you said. It now looks like this

main_controller.rb
[code]
class MainController < ApplicationController
  def welcome
    @product = Product.new
  end
end
[/code]

There is no error now, the partial is rendered. But now i have another question.
When i press the "Create" button on the form, all of the output is
redirected back to the products view.
I want the error messages to the displayed on the welcome view if a user tried
to enter the same product twice.
Is it possible to do that? How?


--~--~---------~--~----~------------~-------~--~----~
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
For more options, visit this group at
http://groups.google.com/group/rubyonrails-talk?hl=en
-~----------~----~----~----~------~----~------~--~---