Category "ruby-on-rails"

Issues regarding the 'rails new' command

I am encountering issues when creating a new application on Ruby On Rails. Whenever I get create a new application on Ruby on Rails, my file was not created suc

Rails - StimulusJS: how to set target value from within setTimeout?

In my Rails-Stimulus controller, I fetch data in a loop from a function in which I've setTimeout. How do I set the target value from within the setTimeout? My f

Ruby on Rails CSRF token creation

The code to create a CSRF token in Ruby on Rails is: def mask_token(raw_token) # :doc: one_time_pad = SecureRandom.random_bytes(AUTHENTICITY_TOKEN

after_commit and after_destroy callbacks are not called on ActiveRecord::Relation delete_by method

I am using ActiveRecord::Relation delete_by method to delete a record but this is not triggering after_commit and after_destroy callbacks. See below example: cl

Why am I getting a nil value from a Ruby object's member, when it is not nil? [closed]

I want to get the value of a field (ScenarioID) in a Ruby ActivityChart object (chart). Displaying the whole chart shows the value I want: 16

React / Rails / I18next change language in URL or refresh server-side props

I'm using React with Rails. I get some props from a React controller when rendering the page initially. When changing the language on the frontend (I18next), we

Rails 5.2 load order breaks db:create

I have a rails application that on Rails 5.1 had no troubles creating MySQL db schemas but fails to create after upgrading to Rails 5.2. It seems like with 5.2

clean way to read out id in a request path in ruby on rails

I have a request that comes in like this: api/v1/photos/1/media/2 "1" and "2" are ids I need to read out in the controller. "2" I can get through the parameters

Login flow with Hotwire

I'm currently developing my first application with Rails and Hotwire. It includes a comment form visible to all users. When unauthenticated users submit it, I'd

How to use and load JS helpers in Stimulus controllers in Rails 7?

I want to import and use functions from my javascript/helpers/functions.js file in my stimulus controllers. I tried pinning it with: # importmap.rb pin_all_from

With RSpec, how do I write an expression that captures _spec files in nested directories?

I’m using Rails 6 with RSpec 3.10. I have the following directory structure spec/models/my_object_spec.rb spec/models/module_name/product_spec.rb I run

When using the friendly_id gem - can you ignore certain routes like /about /contact?

I'm using the friendly_id gem in a Rails application, to be able to view organisations at site.com/organisation-name The problem is that I have a few static pag

Attempting to register a user on my devise app causes undefined method `user_url' for #<Devise::RegistrationsController:0x00000000020ee0>

I am still getting this error when I'm trying to register new user, but I can log in to created user after refreshing page. Here is code which I'm getting on th

ActionController::UnknownFormat After Rails 7 Upgrade

I have a calculator which users would enter in values, hit submit and without refreshing or re-rendering, the calculated values would display on the page. All w

How to wait for all Concurrent::Promise in an array to finish/resolve

@some_instance_var = Concurrent::Hash.new (0...some.length).each do |idx| fetch_requests[idx] = Concurrent::Promise.execute do response = HTTP.get(EXTD

Load a turbo frame with a select OnChange event?

I have a nested form where the nested form items are conditional on the selections in the main form. I have the nested part of the form in a turbo frame. I ha

How do I ensure assets are present with Rail 7, cssbundling-rails, jsbundling-rails in test mode (RSpec)?

I'm upgrading a large, commercial (proprietary) Rails 6 application to Rails 7. We never used Webpacker, and are instead going directly from bundled gems for th

Rails app: I am having trouble creating joint instance

I want to create a simple app where admins can post their job offers and regular users can apply to those job offers. For that I have created a joint table: My

Unable to auto-format *.rb in setting.json below in VScode

I want to auto-format all html, css, sass, rb, and html.erb,js files with setting.json_Vs-code. But the next file after setting.json can only be the above *.rb

Ruby NoMethodError: undefined method

I am using rack-reducer with rails. I am getting the error: #<NoMethodError: undefined method 'order_from_user_input' for #<DataPoint::ActiveRecord_Relati