So I am using rails 6.0.1 and trying to use Action text. So I run the command rails action_text:install
and add the gem image_processing and finally run rails db:migrate
When I launch my app I got this error message:
Sprockets::FileNotFound in Hotels#index
Showing /myapp/app/views/layouts/application.html.erb where line #8 raised:
couldn't find file 'trix/dist/trix' with type 'text/css'
Checked in these paths:
/myapp/app/assets/config
/myapp/app/assets/images
/myapp/app/assets/javascripts
/myapp/app/assets/stylesheets
/usr/local/bundle/gems/cloudinary-1.13.1/vendor/assets/html
/usr/local/bundle/gems/cloudinary-1.13.1/vendor/assets/javascripts
/usr/local/bundle/gems/activeadmin-2.5.0/app/assets/javascripts
/usr/local/bundle/gems/activeadmin-2.5.0/app/assets/stylesheets
/usr/local/bundle/gems/activeadmin-2.5.0/vendor/assets/javascripts
/usr/local/bundle/gems/jquery-rails-4.3.5/vendor/assets/javascripts
/usr/local/bundle/gems/formtastic-3.1.5/app/assets/stylesheets
/usr/local/bundle/gems/actioncable-6.0.1/app/assets/javascripts
/usr/local/bundle/gems/activestorage-6.0.1/app/assets/javascripts
/usr/local/bundle/gems/actionview-6.0.1/lib/assets/compiled
/usr/local/bundle/gems/turbolinks-source-5.2.0/lib/assets/javascripts
/myapp/node_modules
under assets/config/stylesheets/actiontext.scss I have: //= require trix/dist/trix
and config/initiliazers/assets.rb: Rails.application.config.assets.paths << Rails.root.join('node_modules')
Any idea how I could solve this?
I actually find the solution. I had to run yarn install --check-files
then reinstall action_text: rails action_text:install
and then it fixed the issue.
This issue is arises when you are setting up your Rails 6 app for the first time on a new PC. You need to install the JS dependencies. Run these lines of code
bundle install
yarn install --check-files
rails action_text:install
I was getting this same error in my CI pipeline in Github Actions, with a Rails 7 app. The above solutions did not help. It turned out I needed to add yarn builds to my action:
# .github/workflows/verify.yml
- name: Compile assets
run: |
yarn build
yarn build:css
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.