Display link in Rails form error message

后端 未结 6 2037
执笔经年
执笔经年 2021-02-05 18:47

On our sign-up form, we validates_uniqueness_of :email

When the a user is attempting to use our sign up form and they specify an existing email address, I\'

6条回答
  •  挽巷
    挽巷 (楼主)
    2021-02-05 18:52

    After hours trying to figure this out for Rails 4 with devise, I realised you can just add the link directly into the validation:

    # app/models/user.rb
    validates :username, presence: true, uniqueness: {:message => "username has already been taken - search users" }
    

    where the link in this case is my users index. Hopefully this will help someone!

提交回复
热议问题