Questions tagged [ruby-on-rails-5]
For issues specific to version 5.x.y of Rails. If your question applies to Ruby on Rails in general, use the tag [ruby-on-rails].
9,410
questions
0
votes
0
answers
24
views
Rails 5.1: Autoload path is not working even when file present in autoload path
we have a folder called lib in the project folder root and also this in the application.rb
config.autoload_paths += %W(#{config.root}/lib)
but I get a error uninitialized constant ActionView::...
0
votes
0
answers
60
views
Rails 5.1 .any? and .exists? causes unknown column
I'm working with Rails and have encountered an issue with a model that references a table defined in schema.rb as:
create_table "test_table", primary_key: ["somthing", "...
1
vote
1
answer
27
views
(Rails) How to create both sides of a friendship from one nested form insert in Rails?
Basically I have a User model, and a Friendship join table to make the Users friends with each other.
class User < ApplicationRecord
has_many :friendships
has_many :friends, through: :...
0
votes
0
answers
11
views
Rails MySql2 Segmentation fault at 0x0000000000000000
getting error while connecting mysql with rails
here is error logs can any one help ?
there are many error logs but grep some which i think important
rails version - 5.2.3
ruby version - 2.5.1p57
...
0
votes
1
answer
13
views
Error fetching job: Connection refused - connect(2) for "localhost" port 7419
Using Ruby -v 2.7.5 and Rails -v 6.1.7.6
I am using gem 'faktory_worker_ruby', '~> 1.0', for the background jobs.
while starting the faktory demon getting the following error:
Error fetching job: ...
0
votes
2
answers
65
views
Rails has_one association is saved even after the transaction is rollback [closed]
I am upgrading rails 3 app to rails 5 version. I have has_one and belongs_to association. I am saving records in transaction block. in rails 5 i have observed that in case if transaction is rollbacked ...
0
votes
3
answers
49
views
Set two keys for one value in Hash in Rails
Let's say I have a hash:
{
first: :value1,
second: :value1,
third: :value2
}
During .map I need to eliminate duplicates so it should be either first or second only. Is it possible to have some ...
0
votes
1
answer
41
views
Why won't my user profile picture update even though I am getting the correct URL from cloudinary?
When I upload a file, I get a cloudinary url created which is completely fine and works
But when I go perform @user.update, I get this error: ActiveSupport::MessageVerifier::InvalidSignature in ...
0
votes
0
answers
18
views
Omniauth Facebook - Implementation not working in Rails
I keep getting the following page when trying to log in using Facebook in Rails 5.2: Sorry, something went wrong.
We're working on getting this fixed as soon as we can.
The details to the app were as ...
0
votes
0
answers
30
views
JSON::Schema::ValidationError: The property '#/' of type any did not match the following type: object
I use json-schema to validate.When I run these commands:
params = ActionController::Parameters.new({"name": "John Doe","age": 30})
create_schema = {
"type": &...
0
votes
1
answer
21
views
Does bundler search all branches of a repo for the commit when using `ref` option for Gemfile source?
Does bundler search within all branches of a repo for the commit when using ref option for Gemfile source?
gem 'rails', github: 'rails', ref: 'a9752dcfd15bcddfe7b6f7126f3a6e0ba5927c56'
As an example, ...
0
votes
1
answer
32
views
Problem with conditional logic in Rails: instance method does not return expected value
I'm developing a Rails app that allows users to post. I want posts to be anonymous if the anon field in the database is set to 1. To implement this functionality, I added a method in my Post model ...
-1
votes
1
answer
183
views
`rescue in retrieve_store_class': Could not find cache store adapter for dalli_store
Used versions below
rails 5.2.8
ruby 2.3.1
dalli 3.0.4
I receive the following error:
cache.rb:110:in `rescue in retrieve_store_class': Could not find cache store adapter for dalli_store (cannot ...
0
votes
2
answers
61
views
Rails: Determine if attribute on association just changed
We have a Zoo model that has_many Animals. The Zoo model has:
after_commit :update_animals
def update_animals
animals.each(&:do_update_animal)
end
The Animal model (which belongs_to a Zoo) in ...
0
votes
1
answer
55
views
Rails 5 Rspec Trait with associates
I have some doubt with rails 5.2.8 and rspec
To create the object and trait with array associated the rspec code is
let!(:transfer) { Transfer.last }
let!(:transfer_method_type) { create(:...
0
votes
1
answer
36
views
Rails: Truncating HTML-tagged text while preserving link text during truncation in a database column
I have a database column named comment that stores comments containing HTML tags.
To shorten large texts and display them fully in a pop-up, I'm using the truncate(comment, length: 50, escape: false) ...
0
votes
1
answer
73
views
Rails calculating a virtual column using 2 other virtual columns
I need help converting the following MySQL query into an ActiveRecord Query that will produce a relation with IP records as object.
To explain this in a better way, How to convert the following query ...
0
votes
0
answers
21
views
How to utilize an index in PostgreSQL for a similar scenario where MySQL's "USE INDEX" is used [duplicate]
I have a Rails application where I'm currently using PostgreSQL as my database. In one of my methods, I have utilized the "USE INDEX" feature in MySQL to specify a specific index to be used ...
0
votes
1
answer
45
views
Rails + Read XLSX or CSV without fixed headers and key value pair
In Rails trying to read XLSX / CSV file without fixed headers.
For example
1st CSV File, the header will be like user_id, email, dob
2nd CSV File, the header will be like user_id, username, email
So ...
0
votes
1
answer
100
views
How to resize footer text with the Grover Gem in Ruby on Rails 5.2?
def pdf_render(format, file_name, view, orientation, page_size = 'A4', footer="")
@file_name = "#{file_name} [#{date_time_now}]"
html = render_to_string({
...
0
votes
1
answer
24
views
How do turn off printing the authenticity token (CSRF) in Rails 5.2?
This question is not asking how to disable checking the authenticity token in the Rails app (that could be done using skip_forgery_protection inside the controller), but is asking how to avoid ...
1
vote
1
answer
112
views
"Faraday::ConnectionFailed: Broken pipe" when uploading Tempfile to S3 Presigned URL
In my Ruby on Rails application, I need to upload large (~30MB or greater) MP4 video assets to an Amazon S3 Presigned URL using the Faraday Ruby gem. This operation frequently fails with a Faraday::...
0
votes
1
answer
38
views
How to write unit test/ mini test for a class which has self.method with few hardcoded class in that method( I am new at writing tests in ror)?
I have given a task to write unit test in rails for this particular class which was written back in 2017, but since i am new to this and the code stucture is so bad that i am not able to find best way ...
1
vote
0
answers
122
views
Rspec Mysql2::Error: SAVEPOINT active_record_1 does not exist: ROLLBACK TO SAVEPOINT active_record_1
I have upgraded my ruby on rails application from rails 3 to rails 5.2.8 version. in my test case i am trying to save value of 1 megabyte in column. see below test case.
context "validates ...
2
votes
0
answers
154
views
Adding flags when install gem via `bundle install`
I am trying to install mysql2 gem like below and this works
gem install mysql2 -- --with-cflags=\"-I/usr/local/opt/[email protected]/include\" --with-ldflags=\"-L/usr/local/opt/[email protected]/...
0
votes
0
answers
45
views
Rails 5 and Mysql2 gem issue
I am trying to upgrade a Rails 4 app to Rails 5, looks like all went well and also bundle install succeeds. however when I try to start up the server I see two errors in the below sequence
1. ...
2
votes
1
answer
99
views
Shopify/money gem in production: "uninitialized constant ActiveJob::Serializers"
I am attempting to update an older Rails app to run on the heroku-20 stack. I'm running Rails 5.1.1 and shopify-money 1.1.2. It works locally, and everything seemed to deploy correctly to heroku, but ...
0
votes
1
answer
91
views
"We're sorry, but something went wrong" in Rails app related to file upload. How do I debug?
I have a Rails 5 app that contains a lot of basic scaffold-like code. A bunch of models with associated controllers and views for basic CRUD operations. It runs under passenger and with nginx as a ...
0
votes
1
answer
52
views
Explanation on the difference between Rails 4 and Rails 5 association usages in joins and where clauses
Synopsis
I am upgrading a 13 year old Rails 3 application to a Rails 7 application and ran into some hiccups with using associations in where clauses in Rails 5.
Logic
Users are going to have many ...
0
votes
0
answers
29
views
Respond_to format in Rails 5
I am having problems getting respond_to format working in Rails 5 app in controller, is just for downloading a csv list of users, as below:
def customers_graylist_export
@graylisted_users = ...
0
votes
1
answer
49
views
Can someone explain why :null_session still returns this error?
I'm new to rails and having a tough time with the concept of protect_from_forgery, from what i understand this method uses :verify_authenticity_token to protect a route. The route I'm using this on is ...
0
votes
0
answers
95
views
error occurred while installing ovirt-engine-sdk
I am trying to update an old app (Rails 5) on a new computer...
This gem (ovirt-engine-sdk) keep failing (it's not in my gemfile it must be a dependencie of another one... Acually I don't know what it ...
2
votes
1
answer
757
views
can't fix error after bundle update or install
It's an old project that I am trying to reopen (rails 5)
When I run bundle update
I have this :
➜ leschner_ivan bundle update ...
0
votes
0
answers
63
views
How to properly use the gem 'attr_encrypted' during a migration
I am adding the attr_encrypted gem to an existing model.
The problem that I am having is that the data on the migration is not converting.
When I create a new record, I do see it encrypted.
My ...
0
votes
0
answers
42
views
Rails ActiveRecord Association not autosaved on brand new instance
I am upgrading some legacy code from rails 5.0.7.2 (A) to 5.2.8.1 (B) and from Ruby 2.5.0 (A) to Ruby 2.7.7 (B).
In A the following seed file works fine (removed namespace for better readability):
def ...
-3
votes
1
answer
31
views
How to set environment variable inside ubuntu so that they can be access by the nginx, sidekiq and rails application
How to set environment variable in side ubuntu so that they can be access by the nginx, sidekiq and rails application both in development and production environment.
0
votes
1
answer
122
views
Rails 5 error related to postgres Unix domain socket "/tmp/.s.PGSQL.5432"?
I am facing socket issue after reinstalling postgres from my pc Ubuntu 20. Every time I create new project, I have to define host in database.yml otherwise it will throw Unix domain socket "/tmp/...
0
votes
0
answers
113
views
After Upgrade from Rails 4 to Rails 5 getting error NameError: uninitialized constant Sidekiq::Extensions::DelayedModel
I am working on Rails on rails application that has a version
ruby "2.6.6"
gem 'rails', '4.2.11'
gem 'sidekiq', '~> 4.2', '>= 4.2.10'
Now I am upgrading it to Rails 5 with version
...
0
votes
1
answer
31
views
Get records based on quarter values in rails
I have users and expenditures table. Expenditures table has fields called user_id, amount, and entry_date. How can I get old those users whose sum of expenditure in the current quarter is less than ...
3
votes
2
answers
281
views
Rails: has_many through not returning results
We recently upgraded rails to 5.1 following steps in the Rails guide, but see that the following is not working. I have the following model definitions
class User < ActiveRecord::Base
has_many :...
0
votes
0
answers
30
views
ActionController::RoutingError (No route matches [PUT] "/"):
`hey , am trying to implement a reset a password functionality in my app. But am really puzzled up with how am gonna pass this error.
am using ruby as my back end with devise gem and react at the ...
1
vote
1
answer
284
views
How to provide Rails websocket to an existing client (any generic message)?
After trying different things in an attempt to get this working, I haven't managed to yet wrap my head around Rails' magical values in order to provide a websocket interface. Client code is known to ...
0
votes
0
answers
20
views
How do I render an easypost address by id from a user?
I am trying to find the address by the "address_id" column in the user model to then render that address.
Note: Since this is easypost I did not make the address model itself and there is no ...
0
votes
0
answers
164
views
Rails: How to fix Invalid path parameters: Invalid encoding for parameter: �
For Rails v5 and 6, get requests to /%C0 will generate an exception:
An ActionController::BadRequest occurred in #:
Invalid path parameters: Invalid encoding for parameter: �
So, to say it another ...
0
votes
3
answers
47
views
sort results with method defined in rails model
I have a users table and a contracts table and there relationship is as below:
user.rb
has_many :contracts
def current_year_contracts
total = 0
contracts.where('entry_date >= ?', Date.current....
0
votes
0
answers
20
views
my rails application is ignoring the file javascript/packs/application.js
I've been adding "requires" in the javascript/packs/application.js file and it seems to ignore them, I even tried to do
require("file_invented") and didn't get any error, what ...
0
votes
1
answer
42
views
Ruby catching class level 'not implemented' exception
This is probably impossible but I'll ask anyway.
I dynamically create CLASS methods from a database table. I've run out of env var space on AWS. So I have a table with name/value pairs and ...
0
votes
0
answers
39
views
Oauthresponse.parsed gave empty string in rails 7?
I have updated my rails version to 7, here when I try to get parsed from the oauth response it always returns an empty string, but not the parsed response, but in rails 4 it gave the parsed response.
...
1
vote
0
answers
69
views
using PostgreSQL in Rails , search with ILIKE when Value have brackets
using PostgreSQL in Rails, i have a model Logs with attribute value:
I have this Log:
Id:46
Value: "Requirement already satisfied: jedi>=0.16 in /opt/conda/lib/python3.8/site-packages (from ...
0
votes
1
answer
70
views
Render the body via different method in rails
i have been working on a specific use case, where we need to render something like
render body: nil
render nothing: true
so these two things has to used in different methods, like
def render_method
...