Sometimes this happens when you have code like this:
def create
@foo = Foo.new(params[:foo])
if @foo.valid?
flash[:success] = ''Foo created.''
redirect_to :action => ''show'', :id => @foo
else
render :action => ''new''
end
end
If it works on a successful create but not on a render to
''new'' then
you are likely loading objects in the ''new'' action that is not
loaded
in ''create''.
Example:
def new
@foo = Foo.new
@bars = Bar.find(:all)
end
When you render the ''new'' template from the create action you
may need
to reload the @bars (in this example).
Hope this helps.
--
Zack Chandler
http://depixelate.com
On 3/20/07, jko170 <jko170-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
wrote:>
> I have two actions, create and index. The index view has a list of
> find(:all) objects and also a form for creating new objects. If the
> form is valid upon creation, everything works (it is redirected to the
> index page with the new object listed). If validation fails, I get the
> error. My questions is, is it possible to do something like this?
>
>
> >
>
--~--~---------~--~----~------------~-------~--~----~
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-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org
For more options, visit this group at
http://groups.google.com/group/rubyonrails-talk?hl=en
-~----------~----~----~----~------~----~------~--~---