Ruby on Rails Thursday, December 2, 2010

Marnen Laibow-Koser wrote in post #965706:
> Leonel *.* wrote in post #965703:
>> So instead of
>> ----------------------------------------
>> respond_to do |format|
>> if @user.update_attributes(params[:user])
>> flash[:notice] = 'User was successfully updated.'
>> format.html { redirect_to(:action => 'edit') }
>> else
>> flash[:error] = 'User was not updated.'
>> format.html { render :action => "edit" }
>> end
>> end
>> ----------------------------------------
>> Should I do this?
>> ----------------------------------------
>> if @user.update_attributes(params[:user])
>> flash[:notice] = 'User was successfully updated.'
>> format.html { redirect_to(:action => 'edit') }
>> else
>> flash[:error] = 'User was not updated.'
>> format.html { render :action => "edit" }
>> end
>> ----------------------------------------
>
> If you did that, where would the local variable "format" be defined?
>

Well, you're right, but Edmond said:
"But you have already answered this part by removing the xml section.
Then, I'm sure your code contains no *respond_to* block. It looks very
clean that way (unless you want your app to respond conditionally to
HTTP requests send to it."

--
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@googlegroups.com.
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.

No comments:

Post a Comment