Closed ji closed 11 years ago
Hi Brian, unfortunately my test was wrong and that fix didn't work for me either. It just made the generator display it's USAGE without problems. I've been trying to dive into that problem again since yesterday evening and found out the following things:
I tried to require the InflectorFixes directly in the new_api_version generator. I just wanted to see wether the generator would run then. The result was that the generator broke in another place. This was when the autoload-ed configuration was queried. There i thought, that the autoload-ed configuration is not loaded at all. As it turned out my implication was right. I set a pry debugger binding before the configuration autoload statement in versionist.rb file, ran the generator and to my astonishment the binding didn't hit at all. I first thought that i misunderstood the rails boot up process in regards of loading Railties and started reading more about that. But i couldn't find any discrepancy. The interesting part is that the generator runs fine, when versionist is included in a normal rails app and not a mountable engine. I have the same non-working result with a full engine too. On the other hand we programmed another mountable engine under rails 3.2.3 and used versionist 0.3.1, there the generators worked. So i'm starting to get pretty helpless here and loosing my mind on that case. You asked about my engine. It's a mountable engine, rails version is 3.2.13, versionist 1.0.0.
Thanks for digging into this, Yovoslav. I'd be curious to see if the Versionist 1.0.0 generators work in your Rails 3.2.3 mountable engine. There we can narrow down if it's a Rails problem that was introduced somewhere between 3.2.3 and 3.2.13, or a Versionist problem introduced between 0.3.1 and 1.0.0. Is that something you can easily test?
Hi Brian,
actually it is/was easy to test it, because i already had the working case and environment. The generators did definitely not work on a freshly created mountable engine under rails 3.2.3, neither for version 0.3.1 of versionist nor for 1.0.0. I was able to pry into the starting line of the new_api_version of the generator and it seemed that nothing but just the generator was correctly loaded, the rest of the Railtie was simply ignored by the Rails bootup. So instead of going the route, that was designed for versionist i tried to hack in another solution. I definitely didn't like it, but i just wanted to try it out. I manually required and included the necessary files in the generator (like inflector_fixes and the configuration). That worked fine. If it's in Your design interest i can provide this solution while detecting, wether the generator is executed in a Rails app runtime, or an engine runtime. Until we figure out what exactly the problem is, maybe we can provide this as a temporary solution. Let me know, please. (In my opinion it's a Rails issue)
Best
Oh. In your previous comment you said:
"On the other hand we programmed another mountable engine under rails 3.2.3 and used versionist 0.3.1, there the generators worked."
So you're saying that in fact the generators don't work for ANY Rails 3.2.X version engine, correct?
I agree that this definitely sounds like a Rails issue. Are you planning on filing a Rails issue about this? I'd be curious to hear what they have to say about this.
Yes, i wrote that. I wasn't able to confirm though, that the generators worked for the engine mentioned. A fellow dev at the company i was working at told me that the generators worked. We talked yesterday though and he mentioned he's not sure anymore, maybe he had set up the structure by hand. I cloned the engine yesterday evening and the generator definitely did not work on it. Take that as a definite YES on Your question, wether the generators work on any Rails 3.2.X version.
Let me play a little bit more with Rails and once i'm completely hopeless i will file an issue. Meantime, should i contribute with the solution i have written about in my last comment? Perhaps You could take this one on a separate branch?
Thanks Yovoslav. Yes, I'd be happy to take a look at the solution you have in mind. Send me a PR and I'll take a look.
Thanks again.
I'm unable to use the generators in Rails 3.2.13 and am wondering if what I'm seeing is the same as this issue.
after this:
rails generate versionist:new_api_version v2 V2 --header=name:Accept value:"application/vnd.mycompany.com; version=2"
I get this:
.rvm/gems/ruby-2.0.0-p0@ohana-api/gems/actionpack-3.2.13/lib/action_dispatch/routing/mapper.rb:179:in `default_controller_and_action': missing :action (ArgumentError)
@monfresh The generators work for me on Rails 3.2.13 and Ruby 1.9.3 (can't get Ruby 2.0.0 to work for some reason....)
rails generate versionist:new_api_version v3 V3 --header=name:Accept value:"application/vnd.mycompany.com; version=3"
route api_version(:module => "V3", :header => {:name => "Accept", :value => "application/vnd.mycompany.com; version=3"}) do
end
create app/controllers/v3
create app/controllers/v3/base_controller.rb
create test/functional/v3
create test/functional/v3/base_controller_test.rb
create test/integration/v3
create test/integration/v3/base_controller_test.rb
create app/presenters/v3
create app/presenters/v3/base_presenter.rb
create test/presenters/v3
create test/presenters/v3/base_presenter_test.rb
create app/helpers/v3
create test/helpers/v3
create public/docs/v3
create public/docs/v3/index.html
create public/docs/v3/style.css
Are you sure it's not a routes.rb problem? (http://stackoverflow.com/questions/4568301/why-is-my-development-server-not-loading-default-controller-and-action-missin) Can you paste your routes.rb file here?
I just tried it again and it works now. It must have been a routes.rb problem.
@ji It's been several months since this was opened, and no confirmation there's actually an issue. I'm closing this, but feel free to re-open if this is actually an issue for you.
Hi guys, i'm facing this issue inside a mountable engine, rails 3.2.21, ruby-2.0.0-p645 the error is the same: Error: uninitialized constant Versionist::NewApiVersionGenerator::InflectorFixes.
Did you find some workaround to fix this?
I got it! Basically i tried to run rails g to list generators inside my engine folder and versionist generators were never listed, but inside the dummy app on tests they were listed... Basically i was just requiring versionist inside the lib/gemname.rb, but since i required versionist inside lib/gemname/engine.rb i was able to list the generators from my engine root folder and use them successfully.
:+1: Thanks for following up on this.
Thanks for this. While this fix does get rid of the error message mentioned in Issue #40, it still does not work for me when actually running the generator. The error message indicates the InflectorFixes module is still not being included correctly.
Does it work for you? Curious how your engine is set up (full, mountable, etc). Let me know....