Keavy, Indeed, it would be simpler, but messages with an actions
provide a much better way to persuade customers into doing certain
actions and in turn providing them with a better experience, rather
than them leaving the site because something didn't work.

Marnen, I also find myself thinking that, if the consensus is that
including the necessary modules is OK even if their functionality
isn't usually meant for models, then I'm happy to leave it be :)

Thanks for your input.
--Rob


On Jan 29, 12:07 pm, keavy <keavy.mcm...@gmail.com> wrote:
> Why not just use validates_uniqueness_of, with a custom :message ?
>
> custom-err-msg is handy for custom 
> messages:http://github.com/gumayunov/custom-err-msg
>
> I know that doesn't answer your URL issue, but it would seem a simpler/
> tidier solution even if you still wanted to include the link. I prefer
> to just leave navigation out of notices.
>
> On Jan 29, 9:55 am, Rob Aldred <rald...@gmail.com> wrote:
>
> > Hi,
> > I want to be able to have a more detailed friendly message for users
> > when they register with an email address thats already taken.
>
> > At the moment I have written a small validation method to produce what
> > I want, personally I dont like it because I've had to include modules
> > that shouldn't really be there (ActionController::UrlWriter and
> > ActionView::Helpers)
>
> > I was considering extending the error_message_for method to check for
> > error messages on fields against a list stored in a constant then
> > replacing them in the errors array, but I dont really like that
> > either.
>
> > Does anyone know of a plugin or any suggestions on how I could make
> > this cleaner?
> > Here's what I have so far.
>
> > <pre>
> > class User < ActiveRecord::Base
> >   include ActionController::UrlWriter
> >   include ActionView::Helpers
>
> >   validate :unique_email_address
> > ...
>
> > def unique_email_address
> >       if self.class.find_by_email(email)
> >         errors.add(:email, "The email address #{email} has already
> > been used. Please use a different email address or #{link_to('Sign
> > in',login_path)}.")
> >       end
> >     end
> > ...
> > end
>
> > </pre>
>
> > Thanks
> > --Rob
>
>

-- 
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-t...@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