Search code examples
javascriptruby-on-railsrubyrubygemsstimulusjs

Rails 7: Could not find generator 'stimulus'


I have recently upgraded our application to Rails 7 and want to use Stimulus. I understand that with Rails 7 its comes by default.

I am trying to execute rails generate stimulus Downloader but this results in Could not find generator 'stimulus'.

Are there any additional steps i need to perform to use Stimulus?

Any help here would be great, thanks.


Solution

  • It comes with rails 7 in a form of a gem stimulus-rails:
    https://github.com/hotwired/stimulus-rails#installing-with-installer

    bundle add stimulus-rails
    bin/rails stimulus:install
    

    Everything else also comes in a gem importmap-rails, jsbundling-rails, cssbundling-rails, turbo-rails, tailwindcss-rails - and has an install task which rails runs for you when making a new app with rails new. For existing apps you have to follow install instructions for each gem.