views:

50

answers:

1
validates_presence_of :match,
  :message => "for your name and password could not be found. Did you #{link_to "forget your password", help_person_path}?"

That's what I want to do. I can interpolate variables that are set in the model, but using simple Rails code like "link_to" doesn't seem to work. Which is a bummer.

+1  A: 

You can't and shouldn't call the link_to method from your models. However, you can get access to named routes like this:

class PostHack
    include Rails.application.routes.url_helpers
end

class Post < ActiveRecord::Base
    validates_presence_of :match, 
                          :message => "<a href='#{PostHack.new.send :admin_posts_path}'>My link</a>"
end

Very hackish. I hope you will not use it.

floatless
I will not. I figured out that there could only possibly be one error on the sign-in page anyhow, so I just don't display the model errors and generate the error message in my view.
chadoh