On Aug 5, 9:44 am, DanC <[email protected]> wrote:
> Hi Fred,
>
> You are right about the conditional statement being rubbish.
>
> What I really want is to save users that pass the validations and any
> lines in the csv that fail to get skipped over, but remember the error
> that was generated.
>
Well if you use save rather than save! it won't raise an exception if
the record is invalid. If you want the individual errors they'll be in
your_object.errors.
Fred
> Without rescue the whole action would fail.
>
> I am just not sure how to record those errors and associate them with
> this particular import.
>
> Dan
>
> On 5 Aug, 08:29, Frederick Cheung <[email protected]> wrote:
>
>
>
> > On Aug 5, 12:08 am, DanC <[email protected]> wrote:
>
> > > if @user.save!
> > > @user.roles << member_role
> > > else
> > > record_error(line)
> > > end
>
> > This else statement will never execute since if save! fails it raises
> > an exception. Did you want to use save instead ?
>
> > Fred
--~--~---------~--~----~------------~-------~--~----~
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
-~----------~----~----~----~------~----~------~--~---