Questions tagged [ruby-on-rails-6]

Ruby on Rails 6 is the latest version of Ruby on Rails, "an open-source web framework that's optimized for programmer happiness and sustainable productivity."

2084 questions
22
votes
2 answers

Rails: Use of absolute path in Rails 6

Recently, I've upgraded a Rails app that I'm maintaining to Rails 6 RC2 (coming from 5.2.3). So, right after upgrading, I ran the automated tests (RSpec) and the test output gave me lots of deprecation warnings. One of those warnings…
DJenuil
  • 422
  • 4
  • 12
22
votes
1 answer

Rails 5: Add belongs_to association with custom name to model, and migration

I have a User model and a Question model. I want to add a belongs_to :user association to the Question model, but I want that association to be called author. For example, I would call question.author rather than question.user. Obviously this…
21
votes
1 answer

Couldn't decrypt config/credentials.yml.enc. Perhaps you passed the wrong key?

I recently deleted my local project but did a git clone and picked up from where I last committed. As I tried to upload images to AWS, which was already configured, I got this error: Aws::Sigv4::Errors::MissingCredentialsError in…
21
votes
7 answers

URI::InvalidURIError (bad URI(is not URI?): nil) Active Storage service_url

Config Info rails version 6.0 ruby version 2.7.0 gem 'image_processing', '~> 1.2' storage.yml local: service: Disk root: <%= Rails.root.join("storage") %> development.rb config.active_storage.service =…
Imran Ahmad
  • 2,798
  • 3
  • 28
  • 49
21
votes
2 answers

Rails MySQL ILIKE query

My syntax is off. I want to create a scope by_name that finds all agencies whose name attribute contains the passed in string (case insensitive). Here is what I have: class Agency < ActiveRecord::Base scope :by_name, ->(agency_name) {…
Neil
  • 4,578
  • 14
  • 70
  • 155
20
votes
2 answers

How can I preload concerns in a rails initializer using Rails 6/Zeitwerk?

I'm working with an initializer that does some monkey patching on app start by including some app concerns into a third party lib. Basically: # config/initializers/my_initializer.rb class SomeExternalLib include MyConcern1 include…
Glyoko
  • 2,071
  • 1
  • 14
  • 28
20
votes
5 answers

How to add jquery third party plugin in rails 6 webpacker

I know its simple but with update of rails 6. there is new syntax in rails 6 for manage javascript assets which is maintained by webpacker. //application.js require("@rails/ujs")…
uzaif
  • 3,511
  • 2
  • 21
  • 33
19
votes
2 answers

When to use stylesheet_pack_tag instead stylesheet_link_tag with Rails 6

When creating a new rails project with Rails 6, it creates an application.html.erb with stylesheet_link_tag to load CSS and javascript_pack_tag for javascript files. Now, rails 6 also provide a stylesheet_pack_tag, so my question is, when to use it?…
Sanjay Prajapati
  • 789
  • 1
  • 8
  • 17
19
votes
1 answer

How to fix DEPRECATION WARNING: Class level methods will no longer inherit scoping from in Rails 6.1?

Recently updated my Rails app to 6.0. When I run my tests I get the following deprecation warning from a scope on my Referral model: DEPRECATION WARNING: Class level methods will no longer inherit scoping from `with_all_final_state_fulfillments` in…
19
votes
2 answers

How to ignore a folder in Zeitwerk for Rails 6?

Simple question, but somehow the answer escapes me. In moving to Rails 6 with Zeitwerk, I get: Please, check the "Autoloading and Reloading Constants" guide for solutions. (called from at APP_ROOT/config/environment.rb:7) rails…
Iain Bryson
  • 390
  • 5
  • 11
18
votes
4 answers

CSS and Bootstrap not loading in Rails 6 app when deployed to Heroku

I have a Rails 6 project with the default webpacker. I loaded bootstrap and jQuery by followign a tutorial and everything works locally. Here's the structure of the relevant…
Nigel
  • 985
  • 1
  • 11
  • 16
18
votes
4 answers

Rails 6.1 will return Content-Type header without modification ... use `#media_type` instead

What does this deprecation message mean for me to change when it references this block? def json_response(object, status = :ok) render json: object, status: status end Edit The message: Rails 6.1 will return Content-Type header without…
t56k
  • 6,769
  • 9
  • 52
  • 115
18
votes
4 answers

Rails 5/6: How to include JS functions with webpacker?

I am trying to update a Rails 3 app to Rails 6 and I have problems with the now default webpacker since my Javascript functions are not accessible. I get: ReferenceError: Can't find variable: functionName for all js function triggers. What I did…
SEJU
  • 995
  • 1
  • 9
  • 28
16
votes
1 answer

How should I restart spring in Rails 6

I'm going through the Agile Web Development with Rails 6 book and I got to the end of an "Iteration" and did bin/rails test and got a horrible long ugly dump somewhere in fixtures. (I'm not new to Rails ... just trying to catch up on all the new…
pedz
  • 2,271
  • 1
  • 17
  • 20
16
votes
1 answer

Rails 6 webpacker cannot find module for installed module

in my Rails 6 project, i added jQuery pushMenu with yarn add push-menu from https://www.npmjs.com/package/push-menu Now i can see this in node-modules folder, as push-menu. however, when i try to import or include from packs,…
Umes Bastola
  • 527
  • 2
  • 6
  • 18