[Rails] saving a collection
Wilson Bilkovich
wilsonb at gmail.com
Sun Jan 1 21:13:07 GMT 2006
On 1/1/06, Dan Kubb <dan.kubb at autopilotmarketing.com> wrote:
> > On the other hand, you probably also need to make sure the records are
> > valid, so..
> > good_to_go = true
> > @collection.each do |record|
> > good_to_go = false unless record.save
> > end
> > flash[:notice] = "All records saved. Lunch break!" if good_to_go
> > etc, etc, etc.
>
> You could also do it like this:
>
> good_to_go = @collection.all? { |r| r.save }
>
Nice one. The best posts on this list are the ones that make me feel stupid.
I'm going to rewrite some actions now. :)
More information about the Rails
mailing list