abhaynikam / boring_generators

Boring generators aims to make your development faster by delegating boring setups to us.
https://www.boringgenerators.com/
MIT License
269 stars 25 forks source link

Added a line to config/initializers/devise.rb to accept turbo #70

Open jackparsons93 opened 1 year ago

jackparsons93 commented 1 year ago

Now when a new user is signed up they are redirected to the page they came from, instead of getting an error. And I tested it and it added the config.navigational_formats = ['/', :html, :turbo_stream] line to config/initializers/devise.rb

yshmarov commented 1 year ago

Is just adding the turbo stream format enough? Last time I tried, it didn't help me

jackparsons93 commented 1 year ago

This fixes just one problem to my knowledge, it fixes the user registration page so it does not return an error message. On your destroy_user_session_path you still have to add {data: {turbo: false}} to the button to get a redirect and no errors.

However this does solve one problem and probably should be added to devise configuration IMHO

Thank you for your reply Yaroslav Shmarov. I have talked to you on twitter before and bought your udemy courses.

On Sat, Oct 15, 2022 at 4:41 AM Yaroslav Shmarov @.***> wrote:

Is just adding the turbo stream format enough? Last time I tried, it didn't help me

— Reply to this email directly, view it on GitHub https://github.com/abhaynikam/boring_generators/pull/70#issuecomment-1279706983, or unsubscribe https://github.com/notifications/unsubscribe-auth/ACF446V5CXZBVF7XZVEZKITWDJ36PANCNFSM6AAAAAARFT4CTU . You are receiving this because you authored the thread.Message ID: @.***>

jackparsons93 commented 1 year ago

It solves the issue listed here https://github.com/heartcombo/devise/issues/5439 devise

jackparsons93 commented 1 year ago

Also without config.navigational_formats = ['/', :html, :turbo_stream] you get the following error on the following code <% if current_user %> <%= button_to "sign out" ,destroy_user_session_path, method: :delete%> <%end%> devise 2

abhaynikam commented 1 year ago

@jackparsons93 What are your thoughts on building a new generator which supports Devise with Hotwire & Turbo? If we don't want to do this, I think we should add a new flag to the generator to configure devise settings for turbo_stream(similar to: https://github.com/abhaynikam/boring_generators/blob/main/lib/generators/boring/devise/install/install_generator.rb#L14).

If possible could you also add:

  1. Test cases
  2. changelog entry
  3. Update readme

cc/ @yshmarov WDYT?

jackparsons93 commented 1 year ago

https://github.com/heartcombo/devise/issues/5439. this is where I got information from

I think the best fix to start with devise and turbo, is adding config. navigational_formats = ['/', :html, :turbo_stream] to initializers/devise.rb There maybe more fixes in the future to add

Check out this commit https://github.com/heartcombo/devise/compare/main...nickrivadeneira:devise:navigational-format-turbo-support for a fix that does not work with turbo, I tried to do this first to fix devise and it did not work..... I think it is a good idea to add a new generator for devise and turbo or just add a flag to either enable or disable adding config.navigational_formats = ['/', :html, :turbo_stream]

On Test I can try to add test And I think I can update the Changelog and the readme

All the Best Chris Wilson

On Mon, Oct 17, 2022 at 12:04 AM Abhay Nikam @.***> wrote:

@jackparsons93 https://github.com/jackparsons93 What are your thoughts on building a new generator which supports Devise with Hotwire & Turbo? If we don't want to do this, I think we should add a new flag to the generator to configure devise settings for turbo_stream(similar to: https://github.com/abhaynikam/boring_generators/blob/main/lib/generators/boring/devise/install/install_generator.rb#L14 ).

If possible could you also add:

  1. Test cases
  2. changelog entry
  3. Update readme

cc/ @yshmarov https://github.com/yshmarov WDYT?

— Reply to this email directly, view it on GitHub https://github.com/abhaynikam/boring_generators/pull/70#issuecomment-1280291628, or unsubscribe https://github.com/notifications/unsubscribe-auth/ACF446TIFPSHYOZ2G6QBHXDWDTM7LANCNFSM6AAAAAARFT4CTU . You are receiving this because you were mentioned.Message ID: @.***>

jackparsons93 commented 1 year ago

I made it so you would have to add the flag add_turbo to change navigational formats and it works, however I am still having issues with the testing, on my computer all 3 of the devise test are failing, I am troubleshooting now. Will update.

jackparsons93 commented 1 year ago

I am going to try to run the test again on AWS

jackparsons93 commented 1 year ago

out put from AWS Test of Devise

ubuntu:~/environment/boring_generators (main) $ bundle exec ruby -w -Itest test/generators/devise_install_generator_test.rb

/home/ubuntu/.rvm/gems/ruby-2.6.3/gems/mail-2.7.1/lib/mail/parsers/address_lists_parser.rb:32454: warning: statement not reached /home/ubuntu/.rvm/gems/ruby-2.6.3/gems/mail-2.7.1/lib/mail/parsers/address_lists_parser.rb:32615: warning: statement not reached /home/ubuntu/.rvm/gems/ruby-2.6.3/gems/mail-2.7.1/lib/mail/parsers/address_lists_parser.rb:32651: warning: statement not reached /home/ubuntu/.rvm/gems/ruby-2.6.3/gems/mail-2.7.1/lib/mail/parsers/address_lists_parser.rb:32740: warning: statement not reached /home/ubuntu/.rvm/gems/ruby-2.6.3/gems/mail-2.7.1/lib/mail/parsers/address_lists_parser.rb:32756: warning: statement not reached /home/ubuntu/.rvm/gems/ruby-2.6.3/gems/mail-2.7.1/lib/mail/parsers/address_lists_parser.rb:32822: warning: statement not reached /home/ubuntu/.rvm/gems/ruby-2.6.3/gems/mail-2.7.1/lib/mail/parsers/address_lists_parser.rb:32863: warning: statement not reached /home/ubuntu/.rvm/gems/ruby-2.6.3/gems/mail-2.7.1/lib/mail/parsers/address_lists_parser.rb:32888: warning: statement not reached /home/ubuntu/.rvm/gems/ruby-2.6.3/gems/mail-2.7.1/lib/mail/parsers/address_lists_parser.rb:31984: warning: assigned but unused variable - testEof Run options: --seed 24956

Running:

F

Failure: DeviseInstallGeneratorTest#test_should_skip_devise_model [test/generators/devise_install_generator_test.rb:80]: Expected /^\sgem\s+["']devise["']$/ to match "source 'https://rubygems.org'\ngit_source(:github) { |repo| \"https://github.com/\#{repo}.git\" }\n\nruby '2.7.0'\n\n# Bundle edge Rails instead: gem 'rails', github: 'rails/rails'\ngem 'rails', '~> 6.0.3', '>= 6.0.3.2'\n# Use sqlite3 as the database for Active Record\ngem 'sqlite3', '~> 1.4'\n# Use Puma as the app server\ngem 'puma', '~> 4.1'\n# Use SCSS for stylesheets\ngem 'sass-rails', '>= 6'\n# Transpile app-like JavaScript. Read more: https://github.com/rails/webpacker\ngem 'webpacker', '~> 5.0'\n# Turbolinks makes navigating your web application faster. Read more: https://github.com/turbolinks/turbolinks\ngem 'turbolinks', '~> 5'\n# Build JSON APIs with ease. Read more: https://github.com/rails/jbuilder\ngem 'jbuilder', '~> 2.7'\n# Use Redis adapter to run Action Cable in production\n# gem 'redis', '~> 4.0'\n# Use Active Model has_secure_password\n# gem 'bcrypt', '~> 3.1.7'\n\n# Use Active Storage variant\n# gem 'image_processing', '~> 1.2'\n\n# Reduces boot times through caching; required in config/boot.rb\ngem 'bootsnap', '>= 1.4.4', require: false\n\ngroup :development, :test do\n # Call 'byebug' anywhere in the code to stop execution and get a debugger console\n gem 'byebug', platforms: [:mri, :mingw, :x64_mingw]\nend\n\ngroup :development do\n # Access an interactive console on exception pages or by calling 'console' anywhere in the code.\n gem 'web-console', '>= 3.3.0'\n gem 'listen', '~> 3.2'\n # Spring speeds up development by keeping your application running in the background. Read more: https://github.com/rails/spring\n gem 'spring'\nend\n\ngroup :test do\n # Adds support for Capybara system testing and selenium driver\n gem 'capybara', '>= 3.26'\n gem 'selenium-webdriver'\n # Easy installation and use of web drivers to run system tests with browsers\n gem 'webdrivers'\nend\n\n# Windows does not include zoneinfo files, so bundle the tzinfo-data gem\ngem 'tzinfo-data', platforms: [:mingw, :mswin, :x64_mingw, :jruby]\n".

rails test test/generators/devise_install_generator_test.rb:76

F

Failure: DeviseInstallGeneratorTest#test_should_install_devise_successfully [test/generators/devise_install_generator_test.rb:22]: Expected /^\sgem\s+["']devise["']$/ to match "source 'https://rubygems.org'\ngit_source(:github) { |repo| \"https://github.com/\#{repo}.git\" }\n\nruby '2.7.0'\n\n# Bundle edge Rails instead: gem 'rails', github: 'rails/rails'\ngem 'rails', '~> 6.0.3', '>= 6.0.3.2'\n# Use sqlite3 as the database for Active Record\ngem 'sqlite3', '~> 1.4'\n# Use Puma as the app server\ngem 'puma', '~> 4.1'\n# Use SCSS for stylesheets\ngem 'sass-rails', '>= 6'\n# Transpile app-like JavaScript. Read more: https://github.com/rails/webpacker\ngem 'webpacker', '~> 5.0'\n# Turbolinks makes navigating your web application faster. Read more: https://github.com/turbolinks/turbolinks\ngem 'turbolinks', '~> 5'\n# Build JSON APIs with ease. Read more: https://github.com/rails/jbuilder\ngem 'jbuilder', '~> 2.7'\n# Use Redis adapter to run Action Cable in production\n# gem 'redis', '~> 4.0'\n# Use Active Model has_secure_password\n# gem 'bcrypt', '~> 3.1.7'\n\n# Use Active Storage variant\n# gem 'image_processing', '~> 1.2'\n\n# Reduces boot times through caching; required in config/boot.rb\ngem 'bootsnap', '>= 1.4.4', require: false\n\ngroup :development, :test do\n # Call 'byebug' anywhere in the code to stop execution and get a debugger console\n gem 'byebug', platforms: [:mri, :mingw, :x64_mingw]\nend\n\ngroup :development do\n # Access an interactive console on exception pages or by calling 'console' anywhere in the code.\n gem 'web-console', '>= 3.3.0'\n gem 'listen', '~> 3.2'\n # Spring speeds up development by keeping your application running in the background. Read more: https://github.com/rails/spring\n gem 'spring'\nend\n\ngroup :test do\n # Adds support for Capybara system testing and selenium driver\n gem 'capybara', '>= 3.26'\n gem 'selenium-webdriver'\n # Easy installation and use of web drivers to run system tests with browsers\n gem 'webdrivers'\nend\n\n# Windows does not include zoneinfo files, so bundle the tzinfo-data gem\ngem 'tzinfo-data', platforms: [:mingw, :mswin, :x64_mingw, :jruby]\n".

rails test test/generators/devise_install_generator_test.rb:18

F

Failure: DeviseInstallGeneratorTest#test_should_skip_devise_views [test/generators/devise_install_generator_test.rb:51]: Expected /^\sgem\s+["']devise["']$/ to match "source 'https://rubygems.org'\ngit_source(:github) { |repo| \"https://github.com/\#{repo}.git\" }\n\nruby '2.7.0'\n\n# Bundle edge Rails instead: gem 'rails', github: 'rails/rails'\ngem 'rails', '~> 6.0.3', '>= 6.0.3.2'\n# Use sqlite3 as the database for Active Record\ngem 'sqlite3', '~> 1.4'\n# Use Puma as the app server\ngem 'puma', '~> 4.1'\n# Use SCSS for stylesheets\ngem 'sass-rails', '>= 6'\n# Transpile app-like JavaScript. Read more: https://github.com/rails/webpacker\ngem 'webpacker', '~> 5.0'\n# Turbolinks makes navigating your web application faster. Read more: https://github.com/turbolinks/turbolinks\ngem 'turbolinks', '~> 5'\n# Build JSON APIs with ease. Read more: https://github.com/rails/jbuilder\ngem 'jbuilder', '~> 2.7'\n# Use Redis adapter to run Action Cable in production\n# gem 'redis', '~> 4.0'\n# Use Active Model has_secure_password\n# gem 'bcrypt', '~> 3.1.7'\n\n# Use Active Storage variant\n# gem 'image_processing', '~> 1.2'\n\n# Reduces boot times through caching; required in config/boot.rb\ngem 'bootsnap', '>= 1.4.4', require: false\n\ngroup :development, :test do\n # Call 'byebug' anywhere in the code to stop execution and get a debugger console\n gem 'byebug', platforms: [:mri, :mingw, :x64_mingw]\nend\n\ngroup :development do\n # Access an interactive console on exception pages or by calling 'console' anywhere in the code.\n gem 'web-console', '>= 3.3.0'\n gem 'listen', '~> 3.2'\n # Spring speeds up development by keeping your application running in the background. Read more: https://github.com/rails/spring\n gem 'spring'\nend\n\ngroup :test do\n # Adds support for Capybara system testing and selenium driver\n gem 'capybara', '>= 3.26'\n gem 'selenium-webdriver'\n # Easy installation and use of web drivers to run system tests with browsers\n gem 'webdrivers'\nend\n\n# Windows does not include zoneinfo files, so bundle the tzinfo-data gem\ngem 'tzinfo-data', platforms: [:mingw, :mswin, :x64_mingw, :jruby]\n".

rails test test/generators/devise_install_generator_test.rb:47

Finished in 13.829321s, 0.2169 runs/s, 0.6508 assertions/s. 3 runs, 9 assertions, 3 failures, 0 errors, 0 skips