The closest I''ve gotten to was:
format.js { flash[:notice] = "Attend was not created.
#{@attend.errors[:user_id]}" }
which returns: Attend was not created. ["You are already attending
this event"]
Would be good, without the [""]
On Oct 21, 4:43 pm, Christian Fazzini
<christian.fazz...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
wrote:> Currently, my flash message looks like this: "Attend was not created.
> {:user_id=>["You are already attending this event"]}"
>
> How can i make it return: "Attend was not created. You are already
> attending this event"
>
> Controller / def create:
>
> if @attend.save
> ...
> else
> format.js { flash[:notice] = "Attend was not created.
> #...@attend.errors}" }
> end
>
> ------------
>
> Model:
>
> class Attend < Interaction
> validate :attends_have_to_be_unique
>
> def attends_have_to_be_unique
> unless Interaction.where(:user_id => self.user.id, :type =>
> ''Attend'').blank?
> errors.add(:user_id, "You are already attending this
event")
> end
> end
> end
--
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-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org
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.