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.

Filter by
Sorted by
Tagged with
0
votes
0answers
6 views

Rails Ajax/Controller not properly updating my partial

i'm working through a tutorial to get a rails partial to display stock information using ajax. Everything is working properly and in the console I can see that the div has been updated properly, but ...
-2
votes
0answers
16 views

Rails Asset hot line patching - how to patch on the fly without crashing the server? [closed]

Ruby on rails question, gotta a bit of a complex scenario here: On a production rails environment we have 6 rails instances running on N.Virgina AWS region - all of these instances are hosted as ...
0
votes
2answers
13 views

How to remove an old version of bundler?

The root issue I'm having is this error: You must use Bundler 2 or greater with this lockfile. I get the error even if I just use the rails command with no arguments. When I run gem list bundler I ...
0
votes
0answers
14 views

Fix sql injection on Rails model scope

There is a model scope I have been trying to refactor, Brakeman is complaining about it so I thought it was a good idea to fix it since we were scanned by bots who are looking for our site ...
0
votes
0answers
15 views

I have a problem with a self join in rails 4

Ok so we made a Users class with a Friendship self join class (user has_many :friends through: :Friendsips) All of that works fine. Our problem comes I when trying to find all users that are not ...
0
votes
0answers
5 views

Rails recaptcha suddenly returns false every time (previously working)

class PagesController < ApplicationController before_action :set_title def contact_us @form = ContactForm.new end def contact_us_form @form = ContactForm.new(contact_form_params) ...
0
votes
0answers
15 views

Validations isn't work when edit fields with simple-form

I've created a litle form with a some fields, in my model I used validades function to validates the entry data, it works when I register, but when I want to edit my data, for example sending an empty ...
0
votes
0answers
16 views

Getting 403 Forbidden with Nginx/Rails/Passenger

I inherited a Rails/Passenger/Nignx app that returns a 403 error when attempting to view the site in the browser. The logs give me some variation of this error: 2019/12/05 20:45:47 [error] 22624#...
0
votes
1answer
14 views

Why is Heroku having issues with my assets pipeline in rails 5?

I have completed my own portfolio website and went to push it to heroku. When I go to open the app it only showed a message saying: "We're sorry, but something went wrong. If you are the application ...
0
votes
0answers
11 views

Rails + PostgreSQL: How to get products that have been ordered at least once + get the order # and the manager id

I have these models: class Product < ActiveRecord::Base has_many :orders end class Order < ActiveRecord::Base belongs_to :product end I want to get a list of all products which have been ...
-1
votes
2answers
20 views

Fix rails installation / openssl [closed]

I seem to have completely messed up my rails installation on Mac Catalina. I was working on a project which was running on the server just fine -> I then made the mistake of updating something, which ...
0
votes
0answers
7 views

How can I get the username of the loged in user on heroku console?

I am writing a tool that will info me who is logging in to the Heroku console. I am already getting a message when the console is open, I just can't tell who opened it.
0
votes
0answers
6 views

Rails : Multi-tenancy using Apartment and MySQL

I'm creating an application (on rails 6.0.1) using the Apartment gem & Devise, but i can't figure out how to make it work using MySQL.. I've made all my config and stuff, generating my User ...
0
votes
1answer
20 views

Highcharts with Rails 6

I have a scatter chart made with Highcharts. I now need to add an image to the chart. The image should stick to the top right corner. I'm not sure if this is the best way to add an image, but I've ...
0
votes
0answers
11 views

Postgres bulk insert into multiple schemas

Is there a way to bulk insert data into different schemas in Postgres? Let's say, we have 100 records, 50 of them go to one schema, the other 50 go to another schema. Is there a way to do a bulk ...
0
votes
2answers
16 views

Refactoring special HTML characters

<li class="retro-font">Newsletters&nbsp;&loz;&nbsp;</li> I have the above code designed to create a space and a diamond after each section. It's a retro look style choice. I'...
0
votes
2answers
23 views

how to avoid calling .all from this rails controller code?

how to avoid calling .all from this code? since .all will be load all the items to memory and slow I've tried to combine them but the code is not really that DRY companies_controller.rb def ...
0
votes
0answers
6 views

Swaggard only works for certain controllers

I'm trying to add my UserRequestController to the documentation, using Swaggard, but nothing is showing up. When I do the same in another controller that inherits from the same base it works just ...
-1
votes
0answers
21 views

Rails API has_many_through update attribute in join table from frontend [closed]

I have rails API set like this: Item model: has_many :item_locations, :dependent => :destroy has_many :locations, through: :item_locations Location model: has_many :item_locations, :...
0
votes
0answers
10 views

Error with rbenv at deploying rails 4 application with capistrano

I have rails app with capistrano and I use rbenv. I get error when running cap production deploy:restart DEBUG [62d2cfc8] Running /usr/bin/env [ -d $HOME/.rbenv/versions ] as someaddress DEBUG [...
1
vote
0answers
12 views

Subscribe only to a single stream with RailsEventStore

I intend to project a persistent read-model into a relational database with RailsEventStore. To make this possible I need an input stream with a fixed order and without duplicated events. Therefore I ...
0
votes
0answers
13 views

In Rails, is it normal that autosave run validation and callback if associated model has not changed?

I was wondering if it's a normal behavior in Rails (4.2.11) to run validations and callbacks on associated models (with autosave: true) even if they haven't changed? ? My model is : class Customer &...
1
vote
0answers
14 views

Why does GC stat minor_gc_count decrement?

We have an heroku app. When I check GC.stat in the morning, GC.stat[:minor_gc_count] is 51. Later in the day it is 50. From my understanding, this should be the number of times the garbage ...
0
votes
1answer
16 views

How does one make sure that their rails environment on one machine is the same as another?

I have three macs. I have a rails app, that I can run on two of them. On the third, I can create a new rails app and it works fine and some of my other rails apps from the other machines work fine, ...
0
votes
0answers
7 views

Mute assets requests in development log (config.assets.quiet = true doesn't work)

Has anyone managed to mute assets logging in Rails 6. config.assets.quiet = true does't work, I tried all options I could find
0
votes
0answers
12 views

How to update Ruby On Rails app code aws ec2 instance

Any AWS experts there? I was wondering let say if we have rails app deployed on aws ec2 on 2 instances. Now if I connect to app over the ssh and update code (ruby code on rails app, just minor ...
0
votes
1answer
11 views

Mongoid Query Embedded Document Return Wrong Record

I have two models Core::User and Core::UserMeta : class Core::User include Mongoid::Document embeds_many :core_user_meta, class_name: 'Core::UserMeta' end class Core::UserMeta include ...
0
votes
2answers
28 views

Add validation to prevent out of range for ActiveRecord::Type::Integer with limit 4

I am running into out of range for ActiveRecord::Type::Integer with limit 4 error when typing a number over 10 digits. I want to add a validation to prevent this error from popping up. this is my ...
0
votes
0answers
13 views

How to convert (“read”) a .key file into .txt?

So I am using gem saml_idp. Now I need to set up the file config/initializer/saml.rb. I have already generated both myCert.crt and myKey.key files. I have been able to convert ("read") myCert.crt ...
0
votes
1answer
12 views

How to post XML string to api Ruby Faraday

I tried to use Faraday library for Ruby to make the next post request for my API: Need to add API-Key = "xxxxxxxxxxxxxxx" to my header and sent XML inside body <time_entry> <issue_id>1<...
0
votes
1answer
19 views

Creating a has_one through relationship

In my reservation form I would like to create a situation where a user can book one room. As I need to have a unique identifier for a room that is reserved, I use a setup where room and reservation ...
0
votes
0answers
10 views

page.goto hangs when using jest-puppeteer to test a Ruby on Rails project

Test file: describe("Messages", () => { beforeAll(async () => { await page.goto("http://dodona.localhost:3000/nl/users/1/token/zeus"); }); it("Check home page title - 2", ...
-1
votes
0answers
15 views

Decrypting ActiveSupport::MessageEncryptor encrypted string in python [closed]

I have data encrypted by ActiveSupport::MessageEncryptor with salt(key). How should I decrypt that data with Python?
0
votes
1answer
11 views

How to set SameSite attribute to 'None; Secure' in Rails3.1.12 and Ruby1.9.3

A cookie associated with a cross-site resource at https://example.com/ was set without the SameSite attribute. It has been blocked, as Chrome now only delivers cookies with cross-site requests if they ...
0
votes
0answers
7 views

How to verify OWASP 7.13 Keys and secrets are zeroed when destroyed

OWASP 7.13 says Verify that sensitive passwords or key material maintained in memory is overwritten with zeros as soon as it no longer required, to mitigate memory dumping attacks. Just ...
1
vote
2answers
34 views

Namespacing module method definition

I accidentally came across this piece of code in Ruby's Postgresql gem: ### Convenience alias for PG::Connection.new. def self::connect( *args ) return PG::Connection.new( *args ) end I played ...
0
votes
2answers
27 views

Convert YAML string to JSON using Ruby

I am able to convert a YAML file to JSON, but I am not able to convert a YAML string to JSON. Is there any other way to convert YAML string to JSON? Sample Input --- :name: :firstname: Guru :...
-2
votes
1answer
29 views

How to use query parameter like strong parameter?

How can i use query parameter as a strong parameter. This is my POST /tag method called by frontend to search posts. def tag if params[:category] == 'Shop' render json: ShopPostPopulator.new(...
1
vote
0answers
24 views

Active record store with nested hashes

Using the ActiveRecord::Store for serialization, the docs give the following example implementation: cass User < ActiveRecord::Base store :settings, accessors: [ :color, :name ], coder: JSON end ...
0
votes
1answer
20 views

Rails 5 Strong Parameters not permitting main model

This is driving me batty. I have a relatively straightforward setup, but for some reason the main model I'm trying to pass is unpermitted. The log looks like this: Started POST "/statements" for ::...
0
votes
0answers
24 views

failed to allocate memory (NoMemoryError) when using RAILS_ENV=“production” bundle exec rails c

We just upgraded a Rails app to 4.2 to 5.2, everything is working like a charm in development, but when we try to release the app on our production servers, we can't run any rails related commands (...
0
votes
0answers
19 views

Run callback when association is removed

In a Rails 6 app, I have the following standard association. class Course < ApplicationRecord belongs_to :degree after_save :do_something def do_something puts "done something" end end ...
0
votes
0answers
9 views

tooltipster show but not include content (title) rails

I'm try to fix but it still not working. I'm using gem tooltipster-rails 4.2.6 and here is my code in application.html.erb <% unless /MSIE 8.0/ =~ request.user_agent %> <%= ...
0
votes
0answers
8 views

Invalid Authenticity Token Error for a genuine request

I have a customer who has trouble sending in a registration form on our web site. The form has worked for several other customers, so I don't think the form itself has any errors. The POST request the ...
0
votes
1answer
22 views

Cron expression for running rake task first Thursday of every month

I have written following ruby code in rails application : every '20 8 1-7 * 4' do rake 'data_import:check_for_presence_of_file' end But above rake task is running ever day at 8:20 am GMT. Is there ...
0
votes
0answers
12 views

Architecture/design of creating/updating a dynamic invoice after creating/editing a reservation

For a room booking app, I created an app whereby a customer can book a: room additional options extra_guest not included in the room_price After a finishing the reservation, I'm create an invoice ...
0
votes
0answers
20 views

Rails can't find webpacked files

I keep trying to follow the various "How to create a react/rails app" guides but for some reason my rails server is never able to find my packed files I create the app with this: rails 5.2.3 new ...
0
votes
1answer
24 views

In a Rails app running on multiple servers, how can I make sure a rake task runs only once?

I have a Rails app running on 2 servers in production. I have a rake task that runs some import and then sends out an email to the users. I receive 2 emails now since there are 2 servers. To avoid ...
0
votes
1answer
33 views

BUILD FAILED (OS X 10.15.1 using ruby-build 20191124) when installing ruby-2.4.0 with rbenv in OSX catalina(10.15.1)

I tried a lot of things from online forums. But never worked. Installed Xcode to see if it works. But it doesn't. At first, there was an issue with the C executables at the time of the OpenSSL ...
0
votes
0answers
20 views

Could not load OpenSSL while installing bundle in Mac OS

getting bellow error while executing bundle install in Mac OS Could not load OpenSSL. You must recompile Ruby with OpenSSL support or change the sources in your Gemfile from 'https' to 'http'. ...