Closed tombu closed 11 years ago
@tombu #44 was due to an incompatibility with module name cases introduced in the Rails inflector in Rails 4. What specific error are you getting due to the new hash syntax? (And while we're at it, have you had a chance to try the fix for #44 yet? I'd really like to release that fix, but want a second person to verify it fixes the case problem for them in Rails 4).
Let me know what error you're getting due to the hash syntax so I have some context for the PR above. Thanks!
When I use the generator like this:
$ rails g versionist:new_controller foos V1
I get the following output:
create app/controllers/v1/foos_controller.rb
/Users/Thommy/.rvm/gems/ruby-2.0.0-p0/bundler/gems/versionist-18602b9eabd1/lib/generators/versionist/new_controller/new_controller_generator.rb:19:in `block in new_controller': API version doesn't exist in config/routes.rb. Please run 'rails generate versionist:new_api_version' generator first (RuntimeError)
This error led me to the regular expression I mentioned above.
@tombu ah ha, I see the issue now, thanks. This same problem exists in the copy_api_version
generator as well. I'll merge your change in and add specs and fix the other generator as well. Stay tuned....
Nice, thanks. I haven´t used the copy_api_version
generator yet hence I didn´t recognize the issue there. Thanks for your help. I appreciate your work!
versionist 1.2.1 has this fix. Thanks again.
As already mentioned in #44 I encountered problems with the
new_controller
generator when using the new hash syntax (Ruby >= 1.9). I took a look at the generator code and found the problems origin. It´s this regular expression:/api_version.*:module\s*(=>|:)\s*("|')#{module_name_for_route(module_name)}("|')/
in https://github.com/bploetz/versionist/blob/master/lib/generators/versionist/new_controller/new_controller_generator.rb#L15I added a
?
in between the:
andmodule
to make the colon optional.Ruby < 1.9:
=> http://rubular.com/r/yUvIUVf79l
Ruby >= 1.9:
=> http://rubular.com/r/yeXkMTf6Et
Do you want me to add specs for that? If yes, do you have a suggestions to do it without introducing a lot of duplicated code?