Search code examples
ruby-on-railsdevise

authenticate_user error while writing posts ruby-on-rails


my codeI've made an application that only authenticate_user can write post with ruby on rails. but i have a little problem

case: if not logged in user try to access posts/new my app redirects to sign_in path really well but also shows the devise's error message. i want to hide this error

Thanks for reading my question and have a nice day guys


Solution

  • In devise.en.yml file remove the error message, you need to change the error message to blank

    en:
      devise:
        confirmations:
          unauthenticated: "You need to sign in or sign up before continuing."
    

    Change the value of unauthenticated key to blank, it won't display the failure message if user tries to access a page that needs authentication.

    unauthenticated: ""    
    

    Hope that helps!