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

Chapter 3: uninitialized constant ApiConstraints (NameError) #13

Closed
phamtony opened this issue Apr 12, 2015 · 9 comments
Closed

Chapter 3: uninitialized constant ApiConstraints (NameError) #13

phamtony opened this issue Apr 12, 2015 · 9 comments

Comments

@phamtony
Copy link

Hello,

After bundle install, and then doing rails g devise:install, i get this error (screenshot attached)
Do you know why this would be happening?
screen shot 2015-04-12 at 1 08 04 am

@phamtony phamtony changed the title uninitialized constant ApiConstraints (NameError) Chapter 3: uninitialized constant ApiConstraints (NameError) Apr 12, 2015
@phamtony
Copy link
Author

Nevermind, had to put "require 'api_constraints" routes.rb.

@lifeawesome
Copy link

I'm facing this same issue, and I'm a little confused about the solution. Are you saying you need to add "require 'api_constraints' inside the routes.rb file?

@kurenn
Copy link
Owner

kurenn commented May 9, 2015

Yes the solution is to add the api_contraints.rb file on the routes, something like:

require 'api_contraints.rb'
Rails.application.routes.draw do

end

@dgoradia
Copy link

dgoradia commented Aug 6, 2015

I'm getting this same error when doing bundle exec rspec lib/spec/api_constraints_spec.rb. I already have require 'api_constraints' in my routes.rb file.

$ bundle exec rspec lib/spec/api_constraints_spec.rb 
/Users/dgoradia/api/lib/spec/api_constraints_spec.rb:3:in `<top (required)>': uninitialized constant ApiConstraints (NameError)
ruby 2.2.2p95 (2015-04-13 revision 50295) [x86_64-darwin13]
Gem 2.4.8
Rails 4.2.3

@pcofilada
Copy link

I got the same issue @dgoradia-atlas. I think the problem is on the gem version?

@dgoradia
Copy link

dgoradia commented Aug 6, 2015

@pcofilada I think the issue is that I'm using a newer version of RoR. Here is how I fixed it:

In lib/spec/api_contraints_spec.rb, replace:

require 'spec_helper'

with:

require 'rails_helper'

And I added the following to spec/spec_helper.rb since I'm not familiar with the new syntax yet:

expectations.syntax = :should

@pcofilada
Copy link

It's now working @dgoradia-atlas . I think I should use new syntax for my test.

@Jrho19
Copy link

Jrho19 commented Aug 17, 2016

Hey guys, I'm having the same error. Can someone help me out? I tried the code that pcofilada and dgoradia shared. It doesn't work, maybe I'm missing something or because of the newer version.

@jhadeepakkumar14
Copy link

Yes the solution is to add the api_contraints.rb file on the routes, something like:

require 'api_contraints.rb'
Rails.application.routes.draw do

end

please update the spelling of constraints.

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

7 participants