ruby-on-rails-6

Select2 Css is not loading via yarn or assets precompile

坚强是说给别人听的谎言 提交于 2021-01-29 18:01:29
问题 I am running into a strange issue where everything is working as expected except select2. I am having Rails 6.0.0 app and installed select2 via yarn add select2 . Then i added it to application.js file. File looks like below. #app/javascripts/packs/application.js require("@rails/ujs").start() require("turbolinks").start() require("@rails/activestorage").start() require("channels") require('datatables.net') require('datatables.net-dt') require('datatables.net-bs4') require('select2') import

Rails 6.0.2 ActionMailer Issue: Template not found

有些话、适合烂在心里 提交于 2021-01-29 15:07:07
问题 I'm in the development environment. When triggering an email in the UI, I get the error in the browser: No template for interactive request Admins::AdminsController#testmail is missing a template for request formats: text/html NOTE! Unless told otherwise, Rails expects an action to render a template with the same name, contained in a folder named after its controller. If this controller is an API responding with 204 (No Content), which does not require a template, then this error will occur

Use content_for with src attribute of a script tag?

♀尐吖头ヾ 提交于 2021-01-29 08:03:44
问题 I figured out how to use content_for for some elements, for example <title> : <% content_for :title, "Hi, I'm #{@user.username}" %> But I can't seem to get it working when I need to inject a <script> tag with src attribute. I.e. this code: <script src="https://js.stripe.com/v3/"></script> How can I use content_for to place a script tag (with src attribute) in the head of a page? 回答1: Answer from another forum Add this to your head <%= yield :whatever_name_you_want %> And add this to your

Rails 6 convention for declaring namespaced classes? zeitwerk autoloader

爱⌒轻易说出口 提交于 2021-01-29 05:21:07
问题 Curious what the preferred namespaced code should look like in rails 6 which uses zeitwerk for autoloading. Previously I used: # app/controllers/api/users_controller.rb module Api class UsersController def index render json: {} end end end With zeitwerk should we now use: ??? # app/controllers/api/users_controller.rb class Api::UsersController def index render json: {} end end Based on example in https://weblog.rubyonrails.org/2019/2/22/zeitwerk-integration-in-rails-6-beta-2/ it appears the

Cannot find module '@rails/ujs' - Rails 6 Webpack App

被刻印的时光 ゝ 提交于 2021-01-28 01:43:00
问题 I have these errors in a Rails 6 app and all javascript is not working: ERROR in ./app/javascript/packs/application.js Module not found: Error: Can't resolve '@rails/activestorage' in '/Users/jrsahuquillo/Dropbox/myappname/app/javascript/packs' @ ./app/javascript/packs/application.js 9:0-31 ERROR in ./app/javascript/packs/application.js Module not found: Error: Can't resolve '@rails/ujs' in '/Users/jrsahuquillo/Dropbox/myappname/app/javascript/packs' @ ./app/javascript/packs/application.js 5

How to fix this ActionView::Base depreciation with a lookup context?

给你一囗甜甜゛ 提交于 2021-01-27 12:13:11
问题 I migrate an application from rails 5.2 to rails 6. There is only have one thing left to do but I don't know how. I have this depreciation warning: DEPRECATION WARNING: ActionView::Base instances should be constructed with a lookup context, assignments, and a controller. (called from new at /Users/xxx/xxxx/app/models/stock.rb:42) from this code: view = ActionView::Base.with_empty_template_cache.new(ActionController::Base.view_paths, categories: categories, periods: periods) result = view

dotenv gem doesn't get variables in Rails 6 or Ruby 2.6.5

六眼飞鱼酱① 提交于 2021-01-21 05:20:51
问题 I was using the dotenv gem to store environmental variables for development in a secrets file. The gem is no longer pulling the variables after upgrading ruby and rails on my computer. To try and track down the cause, and after a while of trying different options, I ended up creating two identical applications with just two differences. The ruby and the rails versions. One app is able to pull the environmental variables, the other returns nil. Any suggestions? My Setup Working application has

Using Rails 6, where do you put your “page specific” JavaScript code?

纵饮孤独 提交于 2021-01-20 18:01:50
问题 My question here is the same as Using Rails 3.1, where do you put your "page specific" JavaScript code?, just for Rails 6 instead of Rails 3.1. Suppose I have some JavaScript that I want to use for my posts index page. Where do I put that file, and how do I include it? In the previous question the answers usually utilize the Rails Asset Pipeline. However, with Rails 6, my understanding is that it uses webpacker instead of the Asset Pipeline for JavaScript files. Note: I don't want the file to

rails 6 webpacker in production: rake assets:precompile fails

故事扮演 提交于 2021-01-07 21:40:53
问题 I have a typical rails 6.0.2 app set up on a production server and I'm using git hooks to deploy the app. When I try to run: rails assets:precompile I get the following error: rake aborted! Sprockets::ArgumentError: link_directory argument must be a directory /home/user/myapp/app/assets/config/manifest.js:2 Here is the manifest.js file //= link_tree ../images //= link_directory ../stylesheets .css I cant figure out what Im doing wrong. Unless I'm mistaken, doesn't webpacker replace sprockets?

rails 6 webpacker in production: rake assets:precompile fails

前提是你 提交于 2021-01-07 21:32:46
问题 I have a typical rails 6.0.2 app set up on a production server and I'm using git hooks to deploy the app. When I try to run: rails assets:precompile I get the following error: rake aborted! Sprockets::ArgumentError: link_directory argument must be a directory /home/user/myapp/app/assets/config/manifest.js:2 Here is the manifest.js file //= link_tree ../images //= link_directory ../stylesheets .css I cant figure out what Im doing wrong. Unless I'm mistaken, doesn't webpacker replace sprockets?