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

Incompatible with Rails 8 #199

Closed
cvshepherd opened this issue Nov 16, 2024 · 6 comments
Closed

Incompatible with Rails 8 #199

cvshepherd opened this issue Nov 16, 2024 · 6 comments

Comments

@cvshepherd
Copy link

Rails 8 has dropped support for Sprockets in favor of Propshaft, leading to a multitude of app breaking errors when trying to use this gem.

@januszm
Copy link
Contributor

januszm commented Nov 16, 2024

Could you share exact error messages here?

To be honest, I've just started a fresh Rails 8 application with slim-rails and I didn't see any issues with most basic setup and views:

> rails g scaffold Post title body
      invoke  active_record
      create    db/migrate/20241116170917_create_posts.rb
      create    app/models/post.rb
      invoke  resource_route
       route    resources :posts
      invoke  scaffold_controller
      create    app/controllers/posts_controller.rb
      invoke    slim
      create      app/views/posts
      create      app/views/posts/index.html.slim
      create      app/views/posts/edit.html.slim
      create      app/views/posts/show.html.slim
      create      app/views/posts/new.html.slim
      create      app/views/posts/_form.html.slim
      create      app/views/posts/_post.html.slim
      invoke    resource_route
      invoke    helper
      create      app/helpers/posts_helper.rb
❯ bin/rails db:migrate
== 20241116170917 CreatePosts: migrating ======================================
-- create_table(:posts)
   -> 0.0010s
== 20241116170917 CreatePosts: migrated (0.0010s) =============================

> bin/dev
# GET localhost:3000/posts
Started GET "/posts" for ::1 at 2024-11-16
Processing by PostsController#index as HTML
  Rendering layout layouts/application.html.erb
  Rendering posts/index.html.slim within layouts/application
  Post Load (1.1ms)  SELECT "posts".* FROM "posts" /*action='index',application='New8',controller='posts'*/
  ↳ app/views/posts/index.html.slim:6
  Rendered posts/index.html.slim within layouts/application (Duration: 11.4ms | GC: 1.0ms)
  Rendered layout layouts/application.html.erb (Duration: 12.2ms | GC: 1.0ms)

@unRARed
Copy link

unRARed commented Dec 26, 2024

Dunno if related, but I'm getting this with Rails 8 when trying to make a logout button for the new auth pattern:

Screenshot 2024-12-26 at 10 21 21 AM Screenshot 2024-12-26 at 10 22 01 AM

Temporary fix for the logout link:

a href="/session" method="delete" data-turbo-method="delete" Log out

@unRARed
Copy link

unRARed commented Dec 26, 2024

So almost certainly related, it looks like slim-rails is not compatible (yet) with the new Rails 8.0.1 auth generator either (bin/rails generate authentication)

Screenshot 2024-12-26 at 10 39 44 AM

Running again after replacing with just slim (probably same as if no slim in Gemfile) it actually creates the session views:

Screenshot 2024-12-26 at 10 40 51 AM

@taketo1113
Copy link
Contributor

The current version of slim-rails (v3.6.3) does not yet support the authentication generator.
It seems that adding an AuthenticationGenerator, similar to how it's done with rspec-rails, could enable support for it.
rspec/rspec-rails#2811

Other than the authentication generator, the features seem to be working fine with Rails 8.0.
In the following Pull Request, the CI matrix was updated for Rails 8.0, and the tests are passing:


@unRARed The error mentioned in the comment (#199 (comment)) below seems to be a syntax error with button_to, so it doesn't appear to be related to the slim-rails gem.

I believe the error can be fixed by making the following adjustment:

-                = button_to("Log out", session_path,
+                = button_to(session_path,
                   method: :delete,
                   data: { turbo_methid: :delete },
                   class: 'test-blue-500' \
-                )
+                ) do
                   span Log out

@taketo1113
Copy link
Contributor

I also created a PR to support the authentication generator.

@januszm
Copy link
Contributor

januszm commented Dec 29, 2024

Thanks to @taketo1113 , I've just released new gem version with support for authentication generator.

@januszm januszm closed this as completed Dec 29, 2024
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

4 participants