haml / haml-rails

let your Gemfile do the talking
MIT License
1.04k stars 169 forks source link

Unable to convert an application layout of an engine #108

Open petrosp opened 8 years ago

petrosp commented 8 years ago

Hey guys, While the rails g haml:application_layout works fine in nornal Rails app, it does not when I run it from an engine:

~/railsengine$ rails g haml:application_layout
~/railsengine/vendor/bundle/gems/haml-rails-0.9.0/lib/rails/generators/haml/application_layout/application_layout_generator.rb:11:in `convert': undefined method `join' for nil:NilClass (NoMethodError)

I run it correctly without errors under ~/railsengine/spec/dummy:

~/railsengine/spec/dummy$ rails g haml:application_layout
Success! app/views/layouts/application.html.haml is created.
Please remove the erb file: app/views/layouts/application.html.erb

Is haml-rails designed to not to run in Rails engines?

Thanks a bunch.

serv commented 8 years ago

@petrosp I am not familiar with how Rails engines, but I think error is caused by the fact that Rails engine do not have Rails.root where as regular Rails apps do. (Also see: http://stackoverflow.com/questions/5117729/rails-is-there-an-engine-root)

I'll defer to @indirect decide how we should support haml-rails' use case for rails engines.

indirect commented 8 years ago

@petrosp as currently coded, the haml-rails generators do not work with engines. I honestly have no idea how to write generators that work with engines, but I'd be willing to merge a pull request that handles it correctly.