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

Problem with Haml::Rails::Generators when upgrading from haml_rails #142

Open
JohnSmall opened this issue May 31, 2018 · 0 comments
Open

Comments

@JohnSmall
Copy link

Took a while to sort this out, so it would be nice to add something to the read me.

In a Rails 5.2 project I previously had just

gem 'haml_rails'

in my Gemfile, it was happily generating haml for new views. But I didn't have the erb to haml converter so I upgraded to

gem "haml-rails", "~> 1.0"

Which provided the utililty to convert my application layout to haml. But it also completely busted view generation so that when I scaffold a new model I now get this error

Could not load generator "generators/haml/scaffold/scaffold_generator". Error: uninitialized constant 
Haml::Rails::Generators.

I commented out the line in config/application.rb

 config.generators do |g|
     g.template_engine :haml

which was there before when I was just using gem 'haml_rails' as the newer gem "haml-rails", "~> 1.0" shouldn't need it (that's the main point of the updated gem). But was still broken.

Finally after a lot of head scratching and wasted time I realised that haml-rails might not be a direct descendent of haml_rails and simply doesn't upgrade cleanly. So I had to remove 'haml_rails' from my installed gems and remove the lib/generators directory which had haml templates and generators in it.

It now works, but.. that lib/generators was incredibly useful because it had templates I could edit to get new views as I wanted them. e.g form_with or boostrap_form_with.

It would be nice to take the code for templates from haml_rails, an old dead project, and use it in haml-rails so that users could have editable templates.

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

1 participant