Reputation: 2504
I have this sessions_controller.rb
class SessionsController < ApplicationController
skip_before_filter :login_joomla_user_or_redirect
def create
session[:joomla_user_id] = params[:joomla_user_id]
redirect_to root_path
end
def destroy
session[:joomla_user_id] = nil
redirect_to root_path
end
end
And a basic route
unless Rails.env.production?
get "login_as/:joomla_user_id" => "sessions#create", :as => :login
get "logout" => "sessions#destroy"
end
I cannot understand why when I try to login with the route the browser return to me:
The action 'create' could not be found for SessionsController
The action is there. Why? I'm migrating this code from Rails 4.2 to Rails 6
Upvotes: 2
Views: 215
Reputation: 2504
Solution: replace max skip_before_filter
that is deprecated with skip_before_action
I don't know why Rails doesn't give another error.
Upvotes: 2
Reputation: 1180
You should make your create
and destroy
methods to a post
and delete
.
See ruby on rails use "create" method in controller as GET not working for a similar question.
See https://guides.rubyonrails.org/routing.html for the official guide on routes.
Upvotes: 0