1,027 questions
-1
votes
1
answer
90
views
How to make jsbundling-rails and yarn work together?
Issue:
jsbundling-rails can not use yarn build on production server.
Cause:
Inability of to access nvm packages through ssh.
After login on server: which yarn > /home/[user]/.nvm/versions/node/v25....
1
vote
1
answer
73
views
How to directly test ActionController::RoutingError for an invalid path in Ruby-on-Rails-7.1?
In Rails Controller tests of an invalid route, this used to work before Rails-7.1 (in Minitest):
assert_raises(ActionController::RoutingError){ get "/non_existent" }
In Rails-7.1 (or later),...
0
votes
1
answer
228
views
Grover Throwing Javascript Timeout Error in Rails App
I'm getting an error when rendering PDFs with Grover gem in a rails app:
Grover::JavaScript::TimeoutError: Timed out after waiting 30000ms
Couple key points:
Using Grover gem on rails 7 app
Fails in ...
0
votes
0
answers
100
views
How to purge attached ActiveStorage files when updating a record in Rails 7?
I'm using Rails 7 with ActiveStorage to handle file uploads on a Post model. Everything works fine for attaching files, but I'm struggling with removing/deleting an attachment when the record is ...
2
votes
1
answer
74
views
Ruby on Rails Enum ArgumentError
I was wondering if someone can see the obvious error I am making. I can't see it.
My Rails 7.2 application relies on an enum for :likelihood and :consequence. Unfortunately, in testing, I am getting ...
0
votes
0
answers
67
views
After Rails update from 6 to 7, Devise flash messages are not available anymore (Turbolinks disabled)
My Rails app uses Devise (4.9.4) and CanCanCan (3.6.1). I just updated it to version Rails version 7. Since then, the flash messages do not appear anymore when registering as a new user.
I have found ...
0
votes
1
answer
133
views
Rails counter cache for has_one :through on Rails 7 and 8
I am struggling to get a counter cache working on a has_one :through and running into some weird behaviour. I want to have a counter_cache on the Company model that caches the number of associated ...
0
votes
1
answer
52
views
Clearing Fragment Caching from Console
I am new to Rails, going through the caching mechanism and facing a few issues in Fragment caching and not being able to get the solution
In development.rb
config.action_controller.perform_caching = ...
0
votes
0
answers
66
views
Image variants are not processed in Rails 7.0.8 using mini_magick
I have recently upgraded from rails 5.2 to rails 7.0.8 and I am using mini_magick to create image variants. But somehow the image variants are not created.
Gem used:
'image_processing', '~> 1.14'
...
1
vote
1
answer
81
views
actioncable connection lost immediately in production
Actioncable subscribe leads to this error in production:
/home/[app]/.rbenv/versions/jruby-9.4.1.0/lib/ruby/gems/shared/gems/actioncable-6.1.6.1/lib/action_cable/connection/stream_event_loop.rb:74
...
0
votes
0
answers
84
views
Arbitrary Class: Uninitialized Constant Error with string.classify.constantize Rails 7
I'm upgrading a rails app from 5.1 to 7.1.5.1. I have the app working well except for the following issue.
When I try to run
pdf_class = "my_arbitrary_class"
pdf_class.classify.constantize
...
1
vote
0
answers
89
views
Waiting for user to activate email link then continuing with the original page in Rails7
Assume the user is going through steps from 1 to 5, in the last step an activation email is sent to user and then there's a message in step 5 telling the user with a loading icon:
"waiting to ...
0
votes
0
answers
58
views
Changing the language of "The form contains 1 error" in Rails7
In rails7, I have a form, but I want the error messages to be displayed in another language, I can change the ones in the validations in the model e.g. user.rb, but the language of the message that ...
0
votes
0
answers
43
views
How to use omniauth-google-oauth2 with a domain and subdomain in rails7?
omniauth-google-oauth2 works fine on the main domain, I have this folder structure:
controllers/auth/google_oauth2_controller.rb
inside google_oauth2_controller I'm using module Auth:
module Auth
...
1
vote
0
answers
51
views
Does changing routing url in rails using translated paths affect google search results?
After doing research, I've learned that having 'underscore' in your url path can affect google search results, from this google recommended URL structure:
Google recommended URL structure
I initially ...
0
votes
1
answer
26
views
image filename doesn't show the name of the image but it only shows numbers in rails7
When I write this code to show image filename for the alt :
<img class="card-img-top" alt="<%= store.main_image.filename %>" draggable="false" src="<%= ...
-1
votes
1
answer
85
views
RubyOnRails use .where query with has_one - belongs_to relationship
Should i always use plural model name when using .where query with has_one relationship?
My models
class User < ApplicationRecord
has_one :role
end
class Role < ApplicationRecord
belongs_to ...
1
vote
1
answer
597
views
after upgrading to rails 7, active record objects no longer show attributes?
When I was on rails 6, when loading a record from the database in the rails console, I would see:
MyFancyModel.last
=> #<MyFancyModel:0x0000000abc123
id: 123,
name: 'my name',
some_column: '...
0
votes
1
answer
49
views
Upgrade Rails-/Webpacker-App with plain JS, VueJS and Stimulus to Importmaps
I want to migrate a Rails project away from Webpacker.
It uses different JS-parts: VueJS 2.6, StimulusJS, plain old Javascript with some JQuery.
Having used Importmaps in some projects i wonder if ...
-1
votes
1
answer
157
views
ActiveRecord not getting id after save
I got my application to weird state - when I create record (in application or in console), it is created in database, object reports to be persisted, but the object has no id (id: nil).
In summary: ...
0
votes
0
answers
90
views
Ransack is not working after updated from rails4 to rails7
Polymorphic associations do not support computing the class.
I am using rails 7.0.8.4, gem 'ransack' and ruby "3.1.6"
Following code generate an error
@q = Audited::Audit.ransack(params[:q])...
0
votes
1
answer
435
views
Warning:: Passing the class as positional argument is deprecated and will be removed in Rails 7.2
serialize :reddoorz_property_ids, type: Object
DEPRECATION WARNING: Passing the class as positional argument is
deprecated and will be removed in Rails 7.2. Please pass the class as
a keyword argument:...
2
votes
1
answer
139
views
RSpec freezing when starting a nested transaction inside of a thread after upgrading to Rails 7.2
I've upgraded a Rails app to Rails 7.2 and some of my tests are hanging. We have some cases more or less like this that freeze when the nested transaction starts:
context 'error', :transactionless do
...
1
vote
1
answer
178
views
How do I pass local variables to view layouts in Rails 7?
I have a view that I'm rendering like this:
action_controller.render_to_string(
layout: 'document',
template: 'administrator/users/export',
encoding: 'UTF-8',
formats: [:pdf],
...
0
votes
0
answers
302
views
The asset "tailwind.css" is not present in the asset pipeline. - in production, no tests involved
Rails version: 7.2.2
Ruby: 3.2.0
I'm deploying an almost-blank app to Dokku. I'm including Tailwind and my asset pipeline is nothing but Sprockets with importmap. There's no CI involved, no tests are ...
0
votes
2
answers
336
views
How to use active_storage blob with image_processing without temporary files on disk?
using Rails 7.2.1.1 and Ruby 3.3.5. Gemfile has gem "image_processing", "~> 1.13.0".
Basically I have a form that allows the company logo to be uploaded, and needs to accept ...
0
votes
3
answers
114
views
Rails STI through model using polymorphic - populates source_type from parent class
Using Rails 7
I am using a Single Table Inheritance (STI) to store some very simple associations. The source object uses has_many associations with the STI models. Following some advice in question ...
1
vote
0
answers
24
views
Rails Client-side form checkbox validation: at least one value must be chosen
How do I check from the client-side if there is at least one checkbox being ticked here?
= form_with model: @form, url: generate_matches_tournament_path(@tournament), method: :post, local: true do |f|
...
1
vote
0
answers
49
views
Rails 7 - ExecJS::RuntimeError: SyntaxError: Unexpected token: operator (=) - production assets:precompile error
Upgrading chart.js from version 2.9.4 to 4.4.4.
Locally(Machine is MAC OS), rails app is generating charts with upgraded version.
When deploying to AWS EC2, Jenkins build is failing with this error ...
0
votes
1
answer
104
views
Tableless model in Rails 7
I am upgrading a Rails app from Rails 3.2 to Rails 7 (don't ask!!). There is a tableless model that was using this gist, but it's no longer working. It looks like the suggestions here no longer work ...
1
vote
1
answer
118
views
No connection pool for 'ActiveRecord::Base' found for the ' ' role
I upgraded our rails application from version 6.0 directly to 7.0. After commenting out the new framework defaults everything seemed to work smoothly but after setting the load_defaults to 7.0 I got ...
1
vote
2
answers
213
views
Possible to remove method in ActiveRecord?
Context: Rails 7.1, only using the DB interaction layers, no web framework, no servers, etc...
I'm sure this is going to ruffle a few feathers, but I keep running into ActiveRecord::...
0
votes
1
answer
42
views
Eager Loading Child Records with Specific Condition
class User < ApplicationRecord
has_many :description_hoge_projects, -> { where(description: "hoge") }, class_name: "Project"
end
users = User.preload(:...
-1
votes
2
answers
80
views
ActiveStorage - Rails API Only
I have a rails-api-only application and want to upload a Logo.
Using Rails 7, Ruby 3.1.2
Gem "image_processing", "~> 1.2"
Able to upload Logo and retrieve the original logo ...
0
votes
1
answer
49
views
belongs_to :through collection association that all belongs to same object
I have the following classes:
class Order
has_many :line_items
end
class LineItem
belongs_to :order
has_many :line_item_production_items
has_many :production_items, through: :...
3
votes
1
answer
2k
views
ActionMailer NoMethodError for preview_path
After upgrading from Rails 6 to 7, I'm getting this error when trying to test out a mailer that was working just fine before.
NoMethodError (undefined method `preview_path=' for ActionMailer::Base:...
0
votes
1
answer
242
views
Problem loading files using importmaps in rails 7
I am working on a rails 7 app that is using importmaps for all JS related stuff. For reference, I am giving the code below.
importmap.rb
# Pin npm packages by running ./bin/importmap
pin "...
1
vote
1
answer
96
views
SendGrid and Rails 7, Heroku in Production error
I have a Rails 7 app using Ruby 3.2.2 up on Heroku. It uses SendGrid to send thank you emails when someone signs up for the newsletter of fills out the contact form. I have the SendGrid account ...
0
votes
1
answer
54
views
How do I order by lower-cased field on an aliased association without manually specifying a join?
I have the following models, with matching tables and FKs.
class Organization < ActiveRecord
end
class Identifier < ActiveRecord
belongs_to :owner, class_name: "Organization"
...
-1
votes
2
answers
113
views
401 Unauthorized with Devise basic auth
I made a Rails install 7.2.1, installed Devise basic. I set in my applications controller:
def after_sign_in_path_for(current_user)
# Assuming 'Dashboard' is a model and you have a show action
...
0
votes
0
answers
59
views
rails : how desabled override accessor when update
I have a methode to overide a field in category model :
def foo
_foo = read_attribute(:foo)
_foo = competition.foo if _foo.nil?
_foo
end
in controller, the update function :
category.update(...
0
votes
1
answer
88
views
No route matches [GET] "/users/sign_out" i can delete my account but not log out
Here is my error:
No route matches [GET] "/users/sign_out"
and this is all routes :
Prefix Verb URI Pattern ...
1
vote
1
answer
71
views
Can I switch to Amazon S3 later in Rails 7 after using local storage?
If I'm using the server's local storage for storing images, can I access those local images later when I switch to Amazon S3 plan?
0
votes
1
answer
52
views
Where are those schema.rb discrepancies coming from?
My whole team is using docker so we have similar versions, some people are on Linux and some on Mac. When I call rails db:schema:dump I see few discrepancies in the resulting diff:
The 1st kind is ...
0
votes
0
answers
53
views
Skip/Add acts_as_list conditionally
I am using a single model for acts_as_list, not sure if it is mandatory to add an associated model.
class TestModel < ApplicationRecord
# need to skip adding a value to position for a specific ...
0
votes
1
answer
87
views
Rail Upgrade to 7.1.4, NoMethodError for jsonb field in Postgres Db
Upgrading a project from Rails 5.2, made it to 7.1.4 and it's producing an odd issue serializing jsonb. Given the lack of information I've found, this appears to be an unusual issue.
The error ...
1
vote
1
answer
456
views
How to include stylesheets from a gem in Rails 7.2
I'm using the simple_calendar gem and it's working great. I'm having trouble getting it to import the stylesheet by doing
application.css
*= require simple_calendar
or
application.tailwind.css
@...
0
votes
2
answers
240
views
Rails Internationalization (I18n) + Turbo Streams: how to change the locale for Turbo Streams?
TL;DR: the components updated with Turbo Streams in my Rails app always use the default locale instead of the currently set locale.
I have a Rails application with multiple engines. I'm implementing ...
0
votes
1
answer
41
views
uninitialized constant API::V2::BaseController::UserApiAccessRecorder when including a concern module in controller
I am including a concern in a controller:
# app/controllers/api/v2/base_controller.rb
class API::V2::BaseController < ActionController::Base
include UserApiAccessRecorder
end
# app/controllers/...
0
votes
0
answers
45
views
How to validate uniqueness with scope when model belongs to a model that belongs to another model
I have a simple situation where we need to have unique SKUs for items for sale. A location has many products and a product has many variants. The SKUs for each variant has to be unique for a location. ...