2010/12/2 Leonel *.* <[email protected]>

> 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?
>

 Remove the format sections. You can do without it them. Your application
knows how to handle html by default.

----------------------------------------
>       if @user.update_attributes(params[:user])
>         flash[:notice] = 'User was successfully updated.'
>         redirect_to(:action => 'edit')
>       else
>        flash[:error] = 'User was not updated.'
>         render :action => "edit"
>      end
> ----------------------------------------
>
> I had the respond_to block because that's how it was programmed by the
> scaffold and wasn't sure if I should remove it or not.
>

Scaffold is a nice thing but .... as Marnen Laibow-Koser wrote:

Yet another reason not to use scaffolding: it generates a lot of junk
> that you won't understand if you're a beginner and you won't need if
> you're experienced...
>
> (It *can* be useful as an example, though.)
>

I do  not want to start a scaffolding fight here, but scaffolding often
creates code that is untidy and eventually becomes unreadable even to the
developer. You can do without it.

I'm sorry if the question seems very basic, I'm barely getting familiar with
> Ruby.
>

This should be a good reason enough to keep scaffolding on hold. You would
probably need to practice coding yourself rather than letting a generator do
the coding for you.

More blessings,


---
Edmond
Software Developer | Baobab Health Trust (http://www.baobabhealth.org/) |
Malawi

Cell:  +265 999 465 137 | +265 881 234 717

*"Leading the Improvement of Health through Information and Communication
Technology in the Developing World" The **Creed* of *Baobab Health*

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

Reply via email to