Ruby 2.7 Rails 7.0.3.1
/home/felipe/.rvm/gems/ruby-2.7.1/gems/zeitwerk-2.6.0/lib/zeitwerk/loader.rb:359:in `rescue in block in set_autoloads_in_dir': wrong constant name Usersession.controller inferred by Module from file (Zeitwerk::NameError)
Possible ways to address this:
- Tell Zeitwerk to ignore this particular file.
- Tell Zeitwerk to ignore one of its parent directories.
- Rename the file to comply with the naming conventions.
- Modify the inflector to handle this case.
usersession.controller.rb:
class SessionsController < ApplicationController
def new
redirect_to user_contacts_path(current_user) if user_signed_in?
end
def create
user = User.find_by(email: params[:session][:email].downcase)
if user && user.authenticate(params[:session][:password])
sign_in(user)
redirect_to user_contacts_path(current_user)
else
flash.now[:danger] = 'Email e Senha inválidos'
render 'new'
end
end
def destroy
sign_out
flash[:warning] = 'Logout realizado com sucesso'
redirect_to entrar_path
end
end
application.rb :
require_relative "boot"
require "rails/all"
# Require the gems listed in Gemfile, including any gems
# you've limited to :test, :development, or :production.
Bundler.require(*Rails.groups)
module App
class Application < Rails::Application
# Initialize configuration defaults for originally generated Rails version.
config.load_defaults 7.0
# Configuration for the application, engines, and railties goes here.
#
# These settings can be overridden in specific environments using the files
# in config/environments, which are processed later.
#
# config.time_zone = "Central Time (US & Canada)"
# config.eager_load_paths << Rails.root.join("extras")
end
end