Questions tagged [ruby-on-rails]
Ruby on Rails is an open source full-stack web application framework written in Ruby. It follows the popular MVC framework model and is known for its "convention over configuration" approach to application development.
ruby-on-rails
338,228
questions
0
votes
0
answers
14
views
Zeitwerk and Namespacing STI Models
I am trying to figure out an issue I am having with my rails app that involves namespacing some sti models.
Originally, I had a collection of sti models located in: app/models/foo
I validated these ...
0
votes
1
answer
27
views
What is best way to set time in a Rails app form so that the time is the same once I enter it and doesn't change?
I have a Rails 7 form where I enter in data to populate a database. I have a start_time and end_time in the form:
<%= f.time_select :start_time, :value => Time.now.strftime('%I:%M %p') %>
<...
0
votes
0
answers
24
views
rails migration to version 7 still defaults to HTML
Having migrated rails from 6.1 to 7.0, forms or button_to are still processing as HTML
<%= button_to change_shops_for_analysis_promotions_path, method: :post, params: {shop_id: shop.id, toggle: 0},...
1
vote
1
answer
26
views
Rails: How does form_with know, which Controller-action to invoke?
Taken this form as an example:
<%= form_with model: @product do |f| %>
<!-- ... --!>
<% end %>
The routes-file:
get "/products", to: "products#index"
get &...
0
votes
0
answers
24
views
How to handle session managment in ruby on rails app with mixed structure monolithic and api using devise and devise jwt
I have a Ruby on Rails 7 app with devise to handle Registration and session managment for 3 models, Admin, Company and Users. Company has_many users, Admin and Company works in the monolithic ...
1
vote
0
answers
21
views
What are the differences between these migrations to make database column non-nullable (Ruby on Rails)?
I have been working with rails recently (pretty new to the whole thing) and I had a question about a concept I was learning about. So I learned about validations that occur at the model-level, but I'm ...
0
votes
0
answers
31
views
Login Issue: Unable to redirect to multiple sub-domain with masquerade
Users cannot maintain their login sessions when switching between different subdomains within the same application.
I have a multi-tenant app. Recently, I successfully installed the devise-masquerade ...
0
votes
0
answers
15
views
Rails 7 ActionMailer SMTP server with ntlm
I try to setup ActionMailer with NTLM. I use this gem https://github.com/macks/ruby-ntlm and this example Ruby/Rails ActionMailer not working with NTLM.
My configuration is:
config.action_mailer....
0
votes
0
answers
21
views
First ruby on rails deploy to Render - mistake appears
Trying to deploy first ROR app to Render. Using following:
original manual from official render's site - https://docs.render.com/deploy-rails#create-a-new-project
https://www.youtube.com/watch?v=...
0
votes
0
answers
21
views
migrating to rails 7 testing manifest.js error
in migrating an application to rails 7.0
the following warning is issued;
DEPRECATION WARNING: ActiveRecord::Base.default_timezone is deprecated and will be removed in Rails 7.1.
Use `ActiveRecord....
0
votes
0
answers
27
views
Heroku : ruby app, issue when i tried to push it
i create an app on ruby on rails with heroku
this app already exist online
now I try to push a new version of this one on heroku, but i have an issue.
i already update my ruby and rails version (...
0
votes
1
answer
34
views
problem installing Rspec with factory_bot. Factories are not registered
I am using rails 7.1.3.4 with rspec-rails 6.1.3 and factory bot.
I have added require 'factory_bot_rails' and config.include FactoryBot::Syntax::Methods in spec/spec_helper.rb
Here is my factory in ...
0
votes
0
answers
12
views
Elastic Beanstalk error 128 "No url found for submodule path 'aws-elastic-beanstalk-cli-setup' in .gitmodules" in Windows
I have inherited a Ruby on Rails app hosted on AWS and managed by Elastic Beanstalk. I have completed the setup, with my AWS credentials, including separate ssh keys for both the staging environment. ...
0
votes
0
answers
28
views
Rails 7.1 Turbo stream not working on localhost, but works when deployed to Heroku
I have a very simple Rails 7.1.3.4 app that is essentially a dashboard, where it uses Turbo Streams to display model attributes in real-time. When I deploy my app to Heroku, everything works as ...
1
vote
1
answer
19
views
How to save emails sent with Noticed gem
I need to save all sent emails to database. The usual way I would do it would be to add a custom delivery job to ApplicationMailer and handle it in that job (I got the idea from https://engineering....
0
votes
1
answer
43
views
Model method not recognizing parameters
I'm building a rails app where users can search through "Playlists", which is an object containing a title, image, and tracks.
I've defined a search method in the Playlist model that takes ...
1
vote
1
answer
38
views
Saving an associated polymorphic object duplicates it
I have two models, one of them being polymorphic and second one being a "parent" one:
class Person
has_one :asset, as: :assetable
accepts_nested_attributes_for :asset
end
class Asset
...
1
vote
1
answer
37
views
Ruby on Rails - How do I access the HTTP status code in my ERB view?
Suppose I have a controller which sometimes renders the view normally, and sometimes renders the view with HTTP status code 409. How do change what is displayed in the view based on the status code?
I....
0
votes
0
answers
16
views
Can't activate jar-dependencies-0.3.10, already activated jar-dependencies-0.4.1
I'm getting this error.
can't activate jar-dependencies-0.3.10, already activated jar-dependencies-0.4.1
Please help me
My project has gem 'jar-dependencies', '0.4.1' but in my system it was ...
0
votes
0
answers
32
views
how do i fix incorrect mysql library version in ruby on rails?
im trying to make an application that connect to a mysql databse, but whatever i do, i kept making zero progress because i cant get past this line
Incorrect MySQL client library version! This gem was ...
0
votes
0
answers
36
views
what is the better way to add conditional routing in rails
I have to change the route in a way that I need to have the original route as well as change the path of the route in a env is available.
this is how I am thinking of doing
custom_org = ENV['...
0
votes
0
answers
25
views
Destroying scheduled jobs from Solid Queue
I have a Rails app that allows users to sign up and add a list of friends or loved ones with their birthdays. The app will then email the user on their loved ones' birthdays (reminder).
To achieve ...
0
votes
0
answers
46
views
MYSQL/Rails Database design for linked objects best practice? [closed]
I have a ruby/mysql question inquiring what the database structure best practice is:
A - The set-up I have 2 objects, (e.g., employees and documents), in this example, I would like to allow some ...
0
votes
1
answer
41
views
Rails: Extended class that calls another extended class
Setup:
We got an initializer (in config/initializers) that requires a file where we define our extensions.
This file does something like this:
module UbiquoExtensions
end
:SomeClass.include!(...
0
votes
0
answers
25
views
localhost:3000 not working when I start a docker container for my Rails project
I was following a tutorial on how to Dockerize a brand new Rails 7 app. I made the Docker container 'distant-mirror' Setting up the Docker container took about two hours, but now I entered in my ...
0
votes
1
answer
33
views
Can I pass an argument and sort using ransack
"I want to display the exact ID at the top when searching.
For example:
select *
from user
order by user.id = 25 DESC, created_at DESC;
How can I implement this using ransack?"
0
votes
0
answers
33
views
HABTM relationship / validates associated: valid? is true even though I don't think it is
I made the following join table to be used in a HABTM relationship between tasks and itself:
create_table :tasks_tasks, id: false do |t|
t.belongs_to(
:dropoff_task,
null: false,
...
0
votes
0
answers
16
views
Issue with rails hotwire trix textarea resize
im trying to create a textarea resize grippie more or less like the SO for a trix textarea with rais stimulus so i set this controller below
the issue is when i pull down the textarea the textarea ...
0
votes
0
answers
23
views
RPush sending APNs 403/InvalidProviderToken
recently I'm struggling with adding APNs feature to my Ruby on Rails(7) project using RPush. I made some wrong config before and that lead to a failed launch of rails s, then I found and fixed it so I ...
0
votes
2
answers
70
views
Model VS Active record in ROR
Can somebody please explain me the difference between model and active record in simple words ?
Is active model and model same ?
PS: Knowledge regarding these topics will be appreciated.
I am newbie ...
0
votes
1
answer
32
views
Why can't I wrap Sidekiq.configure_server in Rails after_initialize?
After upgrade to Rails 6 the initializers/sidekiq.rb is causing deprecation warnings about class autoloading. As a workaround I thought I could wrap the contents of Sidekiq.configure_server in Rails....
0
votes
0
answers
43
views
Rails: problem with "@hotwired/turbo-rails" and redirects
// app/javascript/application.js
import "@hotwired/turbo-rails"
import "controllers"
import "trix"
import "@rails/actiontext"
import Rails from "@rails/ujs&...
1
vote
0
answers
13
views
Ruby/Rails Bunny RabbitMQ Must be one of [:method, :headers, :body, :heartbeat]
I get an error when trying to connect to RabbitMQ.
Error backtrace:
.../amq-protocol-2.3.2/lib/amq/protocol/frame.rb:67:in `decode_header'
Error:
Must be one of [:method, :headers, :body, :heartbeat]
...
0
votes
0
answers
43
views
How to delete cookies in Rails 7.1?
I recently upgraded my Rails app from version 7.0.4.3 to version 7.1.3.4 and cookies.delete stopped working.
I'm setting a cookie in JavaScript with:
document.cookie = `last_guess=value; path=/`;
...
1
vote
1
answer
61
views
Rails Custom Middleware not being recognized in GH CI
I'm using custom middle ware for the first time to normalize error handling. I have my middleware defined in app/middleware/error_handler.rb and using in my main application.rb
...
require_relative &...
0
votes
0
answers
40
views
Generate a PG dump when click a button
im creating a rails app (basically a monolith). currently, im creating a new feature, "when i click some button, it download a sql script with db backup".
i understand that i can execute ...
0
votes
0
answers
30
views
Docker, nginx, Rails, Puma. Static files are not served but should be
I tried to migrate from Passenger to Puma in a Rails 5.2 project. This is a Docker setup using nginx to redirect from http to https and forward the requests to the Rails container. I had this set up ...
1
vote
0
answers
32
views
Rails 7.1 Error when reading active record model from redis cache
We have a problem during upgrade Rails from 7.0.8 to 7.1.3.2 with reading AR models from Redis cache.
We have several places where we cache AR models with Redis:
Rails.cache.fetch("key_name")...
0
votes
1
answer
39
views
Both controller level and Model level metadata simultaneously in the same column of record. how to store in PaperTrail: versions table
I'm encountering an issue with PaperTrail in my Rails application where I'm trying to store both controller-level and model-level metadata in the versions table, but only the controller-level metadata ...
0
votes
0
answers
18
views
:en is not a valid locale when running "rails generate ims_lti:install"
I'm pretty inexperienced with both stackoverflow and Ruby. Please help me to help you to help me.
I'm trying to implement ims-lti in an open source Rails application. When I run rails generate ims_lti:...
0
votes
0
answers
24
views
Storybook Configuration with Ruby on Rails [closed]
I'm trying to follow the view_component-storybook configuration. I've replicated everything on my windows machine and the static preview pages also work. But the storybook playground doesn't render ...
0
votes
2
answers
53
views
Is there an easier way to write this down and prevent duplicate code?
I am using middleman (Ruby on Rails) with HAML.
I have code like this at the beginning of each page:
- if pageversion == "test"
- domain = data.testvars.domain
- action_url = data....
0
votes
0
answers
22
views
Minitest array check in indifferent order
assert_equal [ '2e', 'd4', '9d', '1a' ], ids
is a statement to verify what array one is dealing with. But often, with fixtures, there is no necessarily set order.
How can the test be written to ...
0
votes
1
answer
48
views
How do I remember where user left in rails
In rails how do I remember which page user left at with user login.
When same user comes back he lands on the same page.
I am new to rails not sure how I can approach this problem.
Is there any gem to ...
1
vote
0
answers
27
views
Why Tailwind CSS doesn't works with public/*.html files in my Ruby on Rails project
I'm using Tailwind CSS for my Ruby on Rails project, the CSS works fine with all the layouts in views but it doesn't works with public/*.html files in my project.
I have a 404.html page and a 500.html ...
0
votes
0
answers
43
views
Rails: problem with handle redirect with turbo_stream in apps
In the application, when creating a feature, it was necessary to add hotwired/turbo-rails.
// app/javascript/application.js
import "@hotwired/turbo-rails"
import "controllers"
...
0
votes
1
answer
53
views
Your Ruby version is 2.6.10, but your Gemfile specified 3.3.0
I've gone through all of the fixes for this. I do not/nor have I ever had ruby 2.6.10 installed on this machine. I'm not sure where this came from. I tried regressing to ruby 3.2.0 for something but ...
0
votes
1
answer
95
views
Solid Queue isn't processing jobs in queues
I'm using the Solid Queue library to send emails. I followed the instructions provided in it's README file and videos from the GoRails & Webcrunch. Once the database is setup with Solid Queue ...
0
votes
0
answers
58
views
Error while installing ruby on rails on windows 11
I'm trying to install Ruby on Rails, but when I run the command "gem install rails", PowerShell throws this error:
C:\Users\milos>gem install rails
Using rubygems directory: C:/Users/...
-2
votes
1
answer
42
views
How to convert this sql query to active record query in rails? Need a solution for mysql database [closed]
SELECT *
FROM users
CROSS JOIN JSON_TABLE(campaigns_list, '$[*]' COLUMNS (
campaign_name varchar(100) PATH '$.campaign_name',
campaign_id varchar(100) PATH '$.campaign_id'
)
) AS j
WHERE ...