In the create action, that typically ends up being `render :action => :new`

Garrett Lancaster

------------------------------------------------------------------------

        Frederick Cheung <mailto:frederick.che...@gmail.com>
January 13, 2011 2:41 AM


On 13 Jan 2011, at 05:46, Niklas Nson<niklasn...@meantime.se>  wrote:

The problem:

When the form validates it all works, but if create goes to a error
what to write there ? I need to render the same page (views/casting/
show.html.erb) again to show the error to the user.

Call the render method (there are loads of ways you can call it. I'd expect this approach 
to be covered by almost any "write a something app in 5 minutes" type tutorial

Fred

Please advice me, i have been looking at this for hours.

/Niklas.

--
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@googlegroups.com.
To unsubscribe from this group, send email to 
rubyonrails-talk+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-talk?hl=en.


------------------------------------------------------------------------

        Niklas Nson <mailto:niklasn...@meantime.se>
January 12, 2011 11:46 PM


Background:

On my application users can post Castings [class Casting] now i want
other users to be abel to post Comments on the Castings
[Castingcomment].

Approach:

views/castings/show.html.erb '

<%= render :partial => 'castingcomment_form' %>

app/controllers/castingcomments_controller.rb

def create
@castingcomment = Castingcomment.new( params[:castingcomment] )
if @castingcomment.save
redirect_to :controller => "castings", :action => "show", :id =>
@castingcomment.casting_id
else
# what to write here ?
end
end

The problem:

When the form validates it all works, but if create goes to a error
what to write there ? I need to render the same page (views/casting/
show.html.erb) again to show the error to the user.

Please advice me, i have been looking at this for hours.

/Niklas.


--
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@googlegroups.com.
To unsubscribe from this group, send email to 
rubyonrails-talk+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-talk?hl=en.

<<inline: compose-unknown-contact.jpg>>

Reply via email to