On Thu, Jan 26, 2012 at 12:08, Mohamad El-Husseini
<husseini....@gmail.com> wrote:

> For the sake of example let's say you have an application
> where users list their ducks for sale.

Viaduct?  Vi-a no chicken?  ;-)

> It's best to prevent the user from
> adding a duck if he has reached his limit. This introduces a chunk
> of logic whose place isn't quite clear. Let's put it in the controller:
>
>   def new

I think you're on the right track having a *warning* show up in
ducks_controller#new.  If, as Colin suggested, you have the *model*
check for excessive ducks as well, #create shouldn't need any
alterations from the standard scaffold-generated style.  (At least,
not for this reason.)  It will make the save fail, detected by
#create, which will just render #new again, with the errors carried by
@duck.

> Bearing in mind I'm two weeks into my Rails and Ruby studies,

You're showing a very good grasp of the concepts for only two weeks
in!  Well done!

-Dave

-- 
Dave Aronson:  Available Cleared Ruby on Rails Freelancer
(NoVa/DC/Remote) -- see www.DaveAronson.com, and blogs at
www.Codosaur.us, www.Dare2XL.com, www.RecruitingRants.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+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-talk?hl=en.

Reply via email to