heartcombo / devise

Flexible authentication solution for Rails with Warden.
http://blog.plataformatec.com.br/tag/devise/
MIT License
23.95k stars 5.55k forks source link

Converting views from Erb to Haml causes them to be ignored by Devise #5670

Closed CraigAPayne closed 8 months ago

CraigAPayne commented 8 months ago

Environment

macOS Sonoma (14.2.1) on Apple M1 Pro

Current behavior

I have a minimal Rails project setup to test this. If you require access, I can provide that, but I don't think you'll need more than the below.

I have Devise installed, with a simple User model, and had run 'rails g devise:views'.

I had made an edit to be sure that the 'registration/new.html.erb' was the one in my app/views/devise - and it was.

Then I ran 'html2haml' on all .erb s file, creating .haml versions, and removed the .erb files. I fired up 'rails console' again. This time I get a default version of the view, pulled from the Gem (a warning message might be nice...):

Started GET "/users/sign_up" for 127.0.0.1 at 2024-01-25 14:00:40 -0800 ActiveRecord::SchemaMigration Load (0.0ms) SELECT "schema_migrations"."version" FROM "schema_migrations" ORDER BY "schema_migrations"."version" ASC Processing by Devise::RegistrationsController#new as HTML Rendering layout layouts/application.html.erb Rendering /Users/craigpayne/.rvm/gems/ruby-3.0.0@rails-test/gems/devise-4.9.3/app/views/devise/registrations/new.html.erb within layouts/application <<<<<<<<<<<<< Rendered /Users/craigpayne/.rvm/gems/ruby-3.0.0@rails-test/gems/devise-4.9.3/app/views/devise/shared/_error_messages.html.erb (Duration: 0.2ms | Allocations: 253) Rendered /Users/craigpayne/.rvm/gems/ruby-3.0.0@rails-test/gems/devise-4.9.3/app/views/devise/shared/_links.html.erb (Duration: 0.3ms | Allocations: 621) Rendered /Users/craigpayne/.rvm/gems/ruby-3.0.0@rails-test/gems/devise-4.9.3/app/views/devise/registrations/new.html.erb within layouts/application (Duration: 2.8ms | Allocations: 4396) Rendered layout layouts/application.html.erb (Duration: 19.4ms | Allocations: 42270) Completed 200 OK in 85ms (Views: 23.3ms | ActiveRecord: 1.0ms | Allocations: 273401)

When I put the .erb version of the view (of just the registrations/new.html.erb) back I get:

Started GET "/users/sign_up" for 127.0.0.1 at 2024-01-25 14:05:41 -0800 ActiveRecord::SchemaMigration Load (0.0ms) SELECT "schema_migrations"."version" FROM "schema_migrations" ORDER BY "schema_migrations"."version" ASC Processing by Devise::RegistrationsController#new as HTML Rendering layout layouts/application.html.erb Rendering devise/registrations/new.html.erb within layouts/application. <<<<<<<<<<< Rendered /Users/craigpayne/.rvm/gems/ruby-3.0.0@rails-test/gems/devise-4.9.3/app/views/devise/shared/_error_messages.html.erb (Duration: 0.2ms | Allocations: 253) Rendered /Users/craigpayne/.rvm/gems/ruby-3.0.0@rails-test/gems/devise-4.9.3/app/views/devise/shared/_links.html.erb (Duration: 0.3ms | Allocations: 621) Rendered devise/registrations/new.html.erb within layouts/application (Duration: 2.9ms | Allocations: 4532) Rendered layout layouts/application.html.erb (Duration: 18.6ms | Allocations: 42643) Completed 200 OK in 85ms (Views: 22.4ms | ActiveRecord: 0.9ms | Allocations: 273593)

Note the <<<<<<<<<'s above.

I can push the rails project I have to GitHub, but I don't think you'll need it.

Expected behavior

I expected it to support the Haml version I've just created, rather than apparently simply ignoring it.

Note - I had noticed that the Haml generators had been removed from Devise. It isn't clear to me that Haml processing would necessarily also have been removed. If it has, I think a better Error/Warning is in order, when Devise resorts to it's internal .erb files.

CraigAPayne commented 8 months ago

Somehow didn't get the rails-haml gem installed :(