Недавно я интегрировал мой Rails webapp с Redis/Sidekiq. После игры с тонны конфигураций я понял, что, возможно, что-то испортил, потому что больше не могу войти в мое приложение. После ссылки на этот вопрос: Devise: Suddenly cannot log in anymore Я полагал, что это имеет какое-то отношение к моим config/initializers/session_store.rb, но я полагаю, потому что я не понимаю, как именно этот файл работает, мне сложно отлаживать эту ошибку.Redis + Конфигурация путаницы
Вот реальное сообщение об ошибке при попытке войти в систему с хорошими учетными данными:
ActionController::UrlGenerationError in Devise::SessionsController#create
No route matches {:action=>"show", :controller=>"controllers"} missing required keys: [:id]
Вот мой session_store.rb:
Rails.application.config.session_store :cookie_store, key: '_appname_session'
AppName::Application.config.session_store :redis_store, servers: "redis://localhost:6379/0/session"
Вот мой routes.rb файл:
Rails.application.routes.draw do
resources :controllers
devise_for :users
require 'sidekiq/web'
mount Sidekiq::Web => '/sidekiq'
end
Ссылка на эту ссылку: What is called session store? Я знаю, что хранилище сеансов - это просто s torage для информации о сеансе, но я не уверен, как это переводится в эту ошибку разработки.
Я также есть соответствующий файл Разрабатывают инициализатора и в моей конфигурации/сред/development.rb У меня есть
config.action_mailer.default_url_options = { host: 'localhost', port: 3000 }
согласно документации.
Разрабатывают Initializer:
config.mailer_sender = '[email protected]' #haven't yet had the need to change this
config.secret_key = 'secret_key'
require 'devise/orm/active_record'
config.case_insensitive_keys = [:email]
config.strip_whitespace_keys = [:email]
config.skip_session_storage = [:http_auth]
config.stretches = Rails.env.test? ? 1 : 11
config.reconfirmable = true
config.expire_all_remember_me_on_sign_out = true
config.password_length = 6..128
config.email_regexp = /\A[^@\s][email protected][^@\s]+\z/
config.reset_password_within = 6.hours
config.sign_out_via = :delete
end
'Контроллеры' Controller -> Это реальная странность для меня. У меня нет воспоминаний о том, чтобы сделать это сам, и я не уверен, был ли это побочным продуктом какого-то другого процесса, за которым я последовал, но каким-то образом оказался в моей заявке. Найденный ниже:
class ControllersController < ApplicationController
before_action :set_controller, only: [:show, :edit, :update, :destroy]
# GET /controllers
# GET /controllers.json
def index
@controllers = Controller.all
end
# GET /controllers/1
# GET /controllers/1.json
def show
end
# GET /controllers/new
def new
@controller = Controller.new
end
# GET /controllers/1/edit
def edit
end
# POST /controllers
# POST /controllers.json
def create
@controller = Controller.new(controller_params)
respond_to do |format|
if @controller.save
format.html { redirect_to @controller, notice: 'Controller was successfully created.' }
format.json { render :show, status: :created, location: @controller }
else
format.html { render :new }
format.json { render json: @controller.errors, status: :unprocessable_entity }
end
end
end
# PATCH/PUT /controllers/1
# PATCH/PUT /controllers/1.json
def update
respond_to do |format|
if @controller.update(controller_params)
format.html { redirect_to @controller, notice: 'Controller was successfully updated.' }
format.json { render :show, status: :ok, location: @controller }
else
format.html { render :edit }
format.json { render json: @controller.errors, status: :unprocessable_entity }
end
end
end
# DELETE /controllers/1
# DELETE /controllers/1.json
def destroy
@controller.destroy
respond_to do |format|
format.html { redirect_to controllers_url, notice: 'Controller was successfully destroyed.' }
format.json { head :no_content }
end
end
private
# Use callbacks to share common setup or constraints between actions.
def set_controller
@controller = Controller.find(params[:id])
end
# Never trust parameters from the scary internet, only allow the white list through.
def controller_params
params.require(:controller).permit(:Reminder)
end
end
Поблагодарили бы об этом:
У вас есть что-нибудь подобное 'ControllersController' внутри вашего приложения/контроллеры? Также вы могли бы разместить свой инициализатор Devise? – oreoluwa
Я добавил эту информацию в сообщение выше! – Sunny