Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

NameError - wrong constant name Object.const_get(camel_cased_word) #761

Open
Codcore opened this issue Jun 2, 2022 · 1 comment
Open

Comments

@Codcore
Copy link

Codcore commented Jun 2, 2022

I am trying setup Authlogic gem with rails 7. I have simple controller:

class UsersController < ApplicationController
  def new
    render_page 'Registration'
  end

  def create
    @user = User.new(email: 'codcore@gmail.com', password: 415561)
    if @user.save
      redirect_to root_url
    else
      render_page 'Registration', props: { errors: @user.errors_codes }
    end
  end

  private

  def user_params
    params.require(:user).permit(:name, :surname, :email, :password, :password_confirmation).to_h
  end
end

and simple User model:

class User < ApplicationRecord
  acts_as_authentic do |c|
    c.session_class = Session
    c.crypto_provider = ::Authlogic::CryptoProviders::BCrypt
  end
end

But when I call create action of UsersController, I get error:

NameError - wrong constant name 
      Object.const_get(camel_cased_word)
            ^^^^^^^^^^:
  app/controllers/users_controller.rb:8:in `create'

That error refers to @user.save in UsersController. I can not figure out what is happenning. I tried to debug this line, but did not understand what is going on. Also I tried authlogic gem right from the GitHub repository, but it didn't help.

The most interesing part that all works as intended when I create new instnce of User and then save it from rails console...

@danlaffan
Copy link
Contributor

Hi @Codcore, could you paste in the entire error message? The additional stack trace might indicate other places where would look.

Also, are you sure you want to use a capital R in the name of your registrations template - the Rails convention is to use lowercase filenames.

Cheers, Dan

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants