where do I put the respond_to if there is an if-statement in the controller in rails?
Posted
by Angela
on Stack Overflow
See other posts from Stack Overflow
or by Angela
Published on 2010-06-10T04:49:01Z
Indexed on
2010/06/10
4:52 UTC
Read the original article
Hit count: 172
I have a controller that has if-condition:
def update @contact_email = ContactEmail.find(params[:id])
if @contact_email.update_attributes(params[:contact_email])
flash[:notice] = "Successfully updated contact email."
redirect_to @contact_email
else
render :action => 'edit'
end
end
Where do I put the respond_to block:
respond_to do |format|
format.html {}
format.json {render :jason =>@contact_email}
end
© Stack Overflow or respective owner