Closed juancroca closed 12 years ago
Have you created new components under a module namespace for the version in question? If so, what are the path names for all files in question, and what are the module names within those files?
For what it's worth, I would strongly suggest you avoid the use of underscores in your module names. Rails simply does not consistently honor them correctly across versions of Rails. In my own APIs I have moved away from semantic versioning (v1.2.3 -> V1_2_3) in favor of a simpler v1, v2 versioning scheme due to this issue in Rails. Feel free to +1 my pull request in Rails to fix this. ;-)
right now i have not created any controllers or presenters i only ran the versionist generate command as shown above
Ah, sorry, I missed that. I see the problem now:
api_version(:module => "v1.0", :path=>"v1", :defaults => {:format => :json}, :default => true) do
end
v1.0 is not a valid module name in Ruby. If your public facing version name really is "v1" (which it is because you're using the :path strategy), then simply change your :module to "V1" to match. You'll need to also change the directory names for the controllers/presenters/tests to match as well (change v1.0 to v1). Might be simpler to just git reset --hard HEAD and re-run the generator with the correct params (up to you obviously):
rails generate versionist:new_api_version v1 V1 path:v1
I removed :
app/controllers/v1.0
app/controllers/v1.0/base_controller.rb
spec/controllers/v1.0
spec/controllers/v1.0/base_controller_spec.rb
spec/requests/v1.0
spec/requests/v1.0/base_controller_spec.rb
app/presenters/v1.0
app/presenters/v1.0/base_presenter.rb
spec/presenters/v1.0
spec/presenters/v1.0/base_presenter_spec.rb
public/docs/v1.0
public/docs/v1.0/index.html
public/docs/v1.0/style.css
And ran again the versionist generator
rails generate versionist:new_api_version v1 v1 path:v1
route api_version(:module => "v1", :path=>"v1") do
end
create app/controllers/v1
create app/controllers/v1/base_controller.rb
create spec/controllers/v1
create spec/controllers/v1/base_controller_spec.rb
create spec/requests/v1
create spec/requests/v1/base_controller_spec.rb
create app/presenters/v1
create app/presenters/v1/base_presenter.rb
create spec/presenters/v1
create spec/presenters/v1/base_presenter_spec.rb
create public/docs/v1
create public/docs/v1/index.html
create public/docs/v1/style.css
Now i get the following error :
rake jobs:work --trace
** Invoke jobs:work (first_time)
** Invoke resque:work (first_time)
** Invoke resque:preload (first_time)
** Invoke resque:setup (first_time)
** Invoke environment (first_time)
** Execute environment
** Execute resque:setup
** Execute resque:preload
rake aborted!
undefined local variable or method `v1' for main:Object
/Users/juanroca/Projects/inbed.me/api/app/controllers/v1/base_controller.rb:1:in `<top (required)>'
/Users/juanroca/.rvm/gems/ruby-1.9.2-p290@api/gems/activesupport-3.2.3/lib/active_support/dependencies.rb:469:in `load'
/Users/juanroca/.rvm/gems/ruby-1.9.2-p290@api/gems/activesupport-3.2.3/lib/active_support/dependencies.rb:469:in `block in load_file'
/Users/juanroca/.rvm/gems/ruby-1.9.2-p290@api/gems/activesupport-3.2.3/lib/active_support/dependencies.rb:639:in `new_constants_in'
/Users/juanroca/.rvm/gems/ruby-1.9.2-p290@api/gems/activesupport-3.2.3/lib/active_support/dependencies.rb:468:in `load_file'
/Users/juanroca/.rvm/gems/ruby-1.9.2-p290@api/gems/activesupport-3.2.3/lib/active_support/dependencies.rb:353:in `require_or_load'
/Users/juanroca/.rvm/gems/ruby-1.9.2-p290@api/gems/activesupport-3.2.3/lib/active_support/dependencies.rb:313:in `depend_on'
/Users/juanroca/.rvm/gems/ruby-1.9.2-p290@api/gems/activesupport-3.2.3/lib/active_support/dependencies.rb:225:in `require_dependency'
/Users/juanroca/.rvm/gems/ruby-1.9.2-p290@api/gems/railties-3.2.3/lib/rails/engine.rb:439:in `block (2 levels) in eager_load!'
/Users/juanroca/.rvm/gems/ruby-1.9.2-p290@api/gems/railties-3.2.3/lib/rails/engine.rb:438:in `each'
/Users/juanroca/.rvm/gems/ruby-1.9.2-p290@api/gems/railties-3.2.3/lib/rails/engine.rb:438:in `block in eager_load!'
/Users/juanroca/.rvm/gems/ruby-1.9.2-p290@api/gems/railties-3.2.3/lib/rails/engine.rb:436:in `each'
/Users/juanroca/.rvm/gems/ruby-1.9.2-p290@api/gems/railties-3.2.3/lib/rails/engine.rb:436:in `eager_load!'
/Users/juanroca/.rvm/gems/ruby-1.9.2-p290@api/gems/resque-1.20.0/lib/resque/tasks.rb:54:in `block (2 levels) in <top (required)>'
/Users/juanroca/.rvm/gems/ruby-1.9.2-p290@global/gems/rake-0.9.2.2/lib/rake/task.rb:205:in `call'
/Users/juanroca/.rvm/gems/ruby-1.9.2-p290@global/gems/rake-0.9.2.2/lib/rake/task.rb:205:in `block in execute'
/Users/juanroca/.rvm/gems/ruby-1.9.2-p290@global/gems/rake-0.9.2.2/lib/rake/task.rb:200:in `each'
/Users/juanroca/.rvm/gems/ruby-1.9.2-p290@global/gems/rake-0.9.2.2/lib/rake/task.rb:200:in `execute'
/Users/juanroca/.rvm/gems/ruby-1.9.2-p290@global/gems/rake-0.9.2.2/lib/rake/task.rb:158:in `block in invoke_with_call_chain'
/Users/juanroca/.rvm/rubies/ruby-1.9.2-p290/lib/ruby/1.9.1/monitor.rb:201:in `mon_synchronize'
/Users/juanroca/.rvm/gems/ruby-1.9.2-p290@global/gems/rake-0.9.2.2/lib/rake/task.rb:151:in `invoke_with_call_chain'
/Users/juanroca/.rvm/gems/ruby-1.9.2-p290@global/gems/rake-0.9.2.2/lib/rake/task.rb:176:in `block in invoke_prerequisites'
/Users/juanroca/.rvm/gems/ruby-1.9.2-p290@global/gems/rake-0.9.2.2/lib/rake/task.rb:174:in `each'
/Users/juanroca/.rvm/gems/ruby-1.9.2-p290@global/gems/rake-0.9.2.2/lib/rake/task.rb:174:in `invoke_prerequisites'
/Users/juanroca/.rvm/gems/ruby-1.9.2-p290@global/gems/rake-0.9.2.2/lib/rake/task.rb:157:in `block in invoke_with_call_chain'
/Users/juanroca/.rvm/rubies/ruby-1.9.2-p290/lib/ruby/1.9.1/monitor.rb:201:in `mon_synchronize'
/Users/juanroca/.rvm/gems/ruby-1.9.2-p290@global/gems/rake-0.9.2.2/lib/rake/task.rb:151:in `invoke_with_call_chain'
/Users/juanroca/.rvm/gems/ruby-1.9.2-p290@global/gems/rake-0.9.2.2/lib/rake/task.rb:176:in `block in invoke_prerequisites'
/Users/juanroca/.rvm/gems/ruby-1.9.2-p290@global/gems/rake-0.9.2.2/lib/rake/task.rb:174:in `each'
/Users/juanroca/.rvm/gems/ruby-1.9.2-p290@global/gems/rake-0.9.2.2/lib/rake/task.rb:174:in `invoke_prerequisites'
/Users/juanroca/.rvm/gems/ruby-1.9.2-p290@global/gems/rake-0.9.2.2/lib/rake/task.rb:157:in `block in invoke_with_call_chain'
/Users/juanroca/.rvm/rubies/ruby-1.9.2-p290/lib/ruby/1.9.1/monitor.rb:201:in `mon_synchronize'
/Users/juanroca/.rvm/gems/ruby-1.9.2-p290@global/gems/rake-0.9.2.2/lib/rake/task.rb:151:in `invoke_with_call_chain'
/Users/juanroca/.rvm/gems/ruby-1.9.2-p290@global/gems/rake-0.9.2.2/lib/rake/task.rb:144:in `invoke'
/Users/juanroca/.rvm/gems/ruby-1.9.2-p290@global/gems/rake-0.9.2.2/lib/rake/application.rb:116:in `invoke_task'
/Users/juanroca/.rvm/gems/ruby-1.9.2-p290@global/gems/rake-0.9.2.2/lib/rake/application.rb:94:in `block (2 levels) in top_level'
/Users/juanroca/.rvm/gems/ruby-1.9.2-p290@global/gems/rake-0.9.2.2/lib/rake/application.rb:94:in `each'
/Users/juanroca/.rvm/gems/ruby-1.9.2-p290@global/gems/rake-0.9.2.2/lib/rake/application.rb:94:in `block in top_level'
/Users/juanroca/.rvm/gems/ruby-1.9.2-p290@global/gems/rake-0.9.2.2/lib/rake/application.rb:133:in `standard_exception_handling'
/Users/juanroca/.rvm/gems/ruby-1.9.2-p290@global/gems/rake-0.9.2.2/lib/rake/application.rb:88:in `top_level'
/Users/juanroca/.rvm/gems/ruby-1.9.2-p290@global/gems/rake-0.9.2.2/lib/rake/application.rb:66:in `block in run'
/Users/juanroca/.rvm/gems/ruby-1.9.2-p290@global/gems/rake-0.9.2.2/lib/rake/application.rb:133:in `standard_exception_handling'
/Users/juanroca/.rvm/gems/ruby-1.9.2-p290@global/gems/rake-0.9.2.2/lib/rake/application.rb:63:in `run'
/Users/juanroca/.rvm/gems/ruby-1.9.2-p290@global/gems/rake-0.9.2.2/bin/rake:33:in `<top (required)>'
/Users/juanroca/.rvm/gems/ruby-1.9.2-p290@global/bin/rake:19:in `load'
/Users/juanroca/.rvm/gems/ruby-1.9.2-p290@global/bin/rake:19:in `<main>'
Tasks: TOP => jobs:work => resque:work => resque:preload
The rest is the same as above does anybody have any idea of what could be wrong?
Note the case of the module name I used in my example:
rails generate versionist:new_api_version v1 V1 path:v1
Must be V1 (not v1)
Yes this seems to work thanks a lot
Im trying to add versionist to a project that runs resque and resque scheduler but when trying to start a worker with rake resque:work i get the following error wrong constant name V1.0, does someone have any idea of what could be happening? Do you need any extra info from me?
Here is the full tree:
lib/tasks/resque.rake
config/initializers/resque.rb
config/routes
Versionist Generate