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
5 views

Accessing nested ActionController::Parameters showing wrong value

My feature_params method returns a hash like-> [40] pry(#<FeaturesController>)> feature_params => <ActionController::Parameters {"name"=>"dola", "desc"=>"none", "category"=>"...
0
votes
0answers
10 views

Adding additional fields dynamically to a rails form

Seeing some tutorials I tried to build some nested forms with option to add fields dynamically when a add button is clicked. I am completely new here and finding it difficult to solve the problem as ...
0
votes
0answers
5 views

How to specify server-side S3 encryption via ActiveStorage?

Through paperclip I was able to specify server side encryption for S3, and also specify a content type (for a wonky file) like this: has_attached_file :attachment, s3_permissions: :private, ...
0
votes
0answers
6 views

How to use authenticate_or_request_with_http_token for a http request in Rails?

If use authenticate_or_request_with_http_token in an API application, it works fine as this guide: https://www.mccartie.com/tech/2016/11/03/token-based-api-authentication.html But tried it in a ...
0
votes
1answer
30 views

How to check if for one record two fields have same value?

I am trying to check if two fields have same value for one record in mongodb through rails. I want to check if the value in actual_user_id and user_id are same. JobPosting.where(:actual_user_id => ...
0
votes
0answers
13 views

Searchkick suggestions support for 3 chars words

I'm using searchkick suggestions on my rails app and everything is working fine except suggestions for 3 char words! when i type for example 'Eg' i'm expecting to to 'Egg' suggestion but this doesn't ...
0
votes
1answer
7 views

Acts As Tree: assigning parent to a child with letting parent know about it?

When I manually assign a parent to a child like this: parent = create :rule # I'm using FactoryBot to create test data child = create :rule, parent: parent Then the parent doesn't know about it: ...
0
votes
0answers
19 views

Reopening class and adding method not working

I am trying to add a method to the class Nokogiri::XML::SyntaxError by reopening the class, but Nokogiri::XML::SyntaxError.new("error message").error_message shows undefined method error_message. I ...
0
votes
1answer
22 views

How to group records with positive payment totals only? [duplicate]

I've got this SQL query in my Rails 5 / MySQL powered application that groups people by the sums of their payments: @people = Person.joins(:payments) .where(:payments => {:date =&...
0
votes
1answer
22 views

How to save massive data to database from a web scraper

I am scraping a web page that contains 2M data. First I am scrolling page with watir than getting data with nokogiri. I can get all the data with one request. I need to save all data to the ...
0
votes
1answer
21 views

Rails: This SQL query was called multiple times and my be opthimised for eager loading

I am seeing the above issue in rails simple activerecord query where(email:email).first_or_create! find_or_create_by!(phone_number: phone_number) Both these queries are not part of any other query ...
0
votes
5answers
57 views

Ruby: how to generate unique alphabetic string in ruby

Is there any in built method in ruby which will generate unique alphabetic string every time(it should not have numbers only alphabets)? i have tried SecureRandom but it doesn't provide method which ...
0
votes
0answers
30 views

consumes more than 5 minutes to get the data

I am using graphiql-ruby gem for using graphql. I am trying to get the list of users with its userprofile and its company. However, it consumes more than 5 minutes and hits the api several times. It ...
0
votes
0answers
7 views

During the heavy rails action passenger 6.0.2 use 100% cpu, but passenger 5.1.2 acts normally

I am updating environment and I faced up with the problem, that passenger + nginx behaves different, that on old env. Old env: nginx/1.10.2 passenger 5.1.2 New env: nginx/1.15.8 passenger 6.0.2 ...
0
votes
2answers
31 views

Evaluate stringified json having interpolatable value

Suppose variable b=2 and a stringified json j = '{"b": "#{b}", "c": null}' The desired result is: { "b" => "2", "c" => nil } My observation: Since json string contains null, we can not ...
0
votes
0answers
21 views

Rails custom logger using concerns is not working

I have a logger_module.rb file under app/lib/concerns/ which look like this module Concerns module LoggerModule def logger(text, logs) log_into_file(text, logs) log_into_kibana(...
0
votes
1answer
9 views

Multiple models with Sorcery gem

I have a goal to have a User model and a Vendor model. Think as if User is a company, and Vendor is employees where the company can create multiple employee accounts to associate to the company. I ...
0
votes
1answer
20 views

i'm trying to pass json data to rails controller using post method in rest client

Here i'm trying to save json data to sqlite database using rails controller, but i'm not getting json data to controller parameters In a specific controller I have the below list of params: ...
0
votes
0answers
18 views

Can not access ROR application outside of localhost in EC2 server

I am very new to Ruby on Rails and its deployment on an EC2 . I am trying to do a standard installation of dev.to (an application to write and share articles and discussion), I am following the ...
0
votes
1answer
44 views

Changing sqlite to pg

Could anyone help me with my problem this is my first draft website? I have tried of StackOverflow solutions but it just seems like I keep running into errors This is my database.yml: default: &...
0
votes
4answers
34 views

Saving object parameters via Ajax in Rails

I'm looking for a way to save multiple object parameters to my database from within a form. I'm using Ruby on Rails and right now I have a basic form that uses radio buttons. When the form is ...
0
votes
0answers
17 views

How to link to /.well-known/assetlinks.json in ruby on rails

I am not a ruby coder, In my ruby on rails app I need to link to /.well-known/assetlinks.json I placed the file in /public/.well-known directory. But I can't link to www.mydomain.com/.well-known/...
0
votes
0answers
7 views

Does anyone able to migrate login_engine and user_engine to Rails 3.2 < 4

In rails 1.1.2 application Login_engine is used to login to system. And User_engine for managing permissions. Does anyone still using it latest version or successfully migrated to Rails 4. Want to ...
0
votes
1answer
12 views

Processing file before upload using ActiveStorage

How would I process a file before it's uploaded using activestorage. I need to be able to modify an svg file's content before it actually gets uploaded to S3. Can't seem to find any callbacks.
1
vote
1answer
28 views

stubbing class inside controllers action

Is it possible to stub a class inside controllers action? I want to stub the SomeServiceObject to return falsey value for me to get to the else statement. # controllers/users_controller.rb ... def ...
0
votes
1answer
16 views

Can't load slick-carousel in Rails + webpacker

While trying to load slick-carousel css files via webpacker, the following error is thrown during compilation: ERROR in ./app/javascript/packs/frontend.sass (./node_modules/css-loader/dist/cjs.js??...
0
votes
1answer
24 views

PG ERROR: invalid input syntax for integer when trying to destroy

I get this error whenever I try to destroy a record. I don't get why this isn't working. PG::InvalidTextRepresentation: ERROR: invalid input syntax for integer: "Notation" My controller: def ...
0
votes
0answers
14 views

Route cannot be found Rails 5.2.3 [duplicate]

Rails 5.2.3 In my routes.rb, I have: resources :devices When I do rake routes, I get: devices GET /devices(.:format) devices#index device GET /devices/:id(.:format). devices#show In my devices/...
0
votes
2answers
42 views

Rails - How to group dates by time when they're in different timezones?

I have a series of Appointments where the date and time is stored under start_date as DateTime. I'd like to categorize them as starting in the Morning, Daytime, or Evening. I created an array of ...
0
votes
1answer
25 views

Assets only are being served on page refresh

I have an issue with my javascript files, seems they are not load properly in each redirect from my app. I need make a refresh to get load them. Im using rails 5, and turbolinks 5. This is how my ...
4
votes
1answer
31 views

What's the straightforward, supported, stable way of using ES6 syntax and Javascript minification with Rails?

I'm trying to use ES6 syntax in my Javascript files, in a Rails project. I also need to minify the Javascript files (mine, and the ones included by libraries like rails-ujs) for performance reasons. ...
-2
votes
0answers
23 views

Rails 6 doesn't update view after update template [on hold]

I init new app in Rails 6 and get problem with update view after change template. Can solve this problem only reload server. How I can update config for update view without reload server.
0
votes
0answers
10 views

Rails 6/Rake: Why do my test db files remain after my tests run?

I'm learning how to create tasks to run tests in custom folders. I have: require 'rails/test_unit/runner' namespace :test do task concerns: 'test:prepare' do |t| $LOAD_PATH << './test' ...
0
votes
0answers
17 views

Rails: Integrate External Applications Login API

I am building a digital library, and I have completed a lot of the functionalities needed. I am currently having an issue with integrating the digital library with a Learning Management System (LMS). ...
0
votes
2answers
23 views

Building queries into Rails API requests in the URL

I am trying to begin work on building some API functionality in a Rails app and Im just playing around with the concepts in a simple app where a Movie has_many :reviews and Review belongs_to :movie ...
0
votes
0answers
10 views

SCSS @import statements inside Rails Engine results in error: `Aborted (core dumped)`

I am having trouble using SCSS @import statements within any of my Rails Engines. Can someone please help me sort this out? Here are some details: Using @import within any SCSS files within the Rails ...
0
votes
1answer
14 views

Fixing openproject configuration broken by upgrade

I used apt to install a local version of openproject 9 on ubuntu xenial using apache2 and postgres. I had it working fine for several weeks, and then had the temerity to accept an offered package ...
-1
votes
0answers
21 views

Get current_user with Jwt on www.pluralsight.com exemple

After setup the https://www.pluralsight.com/guides/token-based-authentication-with-ruby-on-rails-5-api jwt exemple! i'd like to get the current_user from the auth! on their exemple they use to auth ...
0
votes
1answer
15 views

Rake aborted PG::ConnectionBad: FATAL: database “vagrant” does not exist

How to run rake db:migrate using postgres user for database my_db. The role postgres and my_db database are created but when try to run migrate command , it throws error. Please let me know if I am ...
0
votes
3answers
43 views

Sorting select results

I'm trying to sort c.description alphabetically but I'm not familiar with Ruby and can't seem to get .sort to work. cakes.select do |cake| cake.categories.pluck(:id).any? do |ca| category....
1
vote
1answer
25 views

Partially preload association based on where condition

I have two models: class Thread < ApplicationRecord has_many :posts end class Post < ApplicationRecord belongs_to :thread belongs_to :user end I would like to write a query that ...
0
votes
0answers
26 views

Can't link to file in public folder of ruby on rails app

In my ruby on rails app I uploaded a file .well-known/assetlinks.json. But I can't go to www.monsoonmalabar.com/.well-known/assetlinks.json. It redirects to root domain. In fact I can't link to any of ...
0
votes
1answer
23 views

Run method in Controller on another page before showing results with Ransack

My question With Ransack, when submit is clicked, is there a way to call a method before displaying the results on another page. Summary I have a page called manualPull that contains a single ...
0
votes
1answer
19 views

GET request params dissapear after sending form to the same page

I have a form on root page that is handled by flights#index and is located at root. I want that form to submit a GET request to the same page, find appropriate flights and display them. Unfortunately ...
0
votes
2answers
33 views

Rails save massive hash data to database

I have a Hash with 2M data. I need to transfer all data from hash to database. Hash keys fit with database columns. I'm not sure the way I use below is the best way. # users is a hash with 2M data. ...
0
votes
0answers
12 views

Issue retreiving dynamic elements with querySelectors in Stimulus controller

When querying elements in my controller, I am not able to retrieve the elements I want, even though when I run the same code in my browser console it finds them perfectly (I can see the id is title1 ...
0
votes
0answers
17 views

JavaScript slider does not work anymore when I come back to the page

The slider works when I load the page for the first time. But when I go off somewhere else and come back to my page, the slider doesn't work anymore. I am forced to refresh the page and then it works ...
0
votes
1answer
19 views

how to create migration on rails with raw sql (postgres) with large data set

I wanted to insert data into a related table. A 1 to many relationships. After searching the best practice I found this link and then I implemented this. class ...
0
votes
0answers
11 views

Will clearing the cache in production have any negative effect on logged in devise users?

If I run Rails.cache.clear on production, will this have any negative effect on users? I need to clear the cache for an update I'm implementing and while I don't notice any negative effect running ...
0
votes
0answers
15 views

Error on creating a custom type in Rails - A copy of Color::Type has been removed from the module tree but is still active!)

I saw some other question about this issue (none of them related to types), but I can't understand what is going on. I've create a new rails application with the following classes # app/types/color....