Search code examples
ruby-on-railsactioncontroller

Strange error: after create user alway redirects ot show?


It is strange. I'm writing custom user registration and want to make redirection to OTHER page after user creation, but it want to call show action.

Here is my controller:

def create
  @user = User.new(params[:user])

respond_to do |format|
  if @user.save
    format.html { redirect_to users_verify_path }
  else
    format.html { render action: "new" }

  end
end

end def verify ... end in routes.rb:

       resources :users

       root :to => 'users#new'

        get "users/verify"

when I rename action into SHOW everything is working. If I name it VERIFY - it shows me:

    Unknown action

    The action 'show' could not be found for UsersController

it is obvious error, because I deleted action show. But WHY it is redirecting to show ?


Solution

  • Try to write get "users/verify" before resources :users

    or

    resources :users do
      member do
        get 'verify'
      end
    end