36,684 questions
1
vote
0
answers
43
views
Mobility in the Ruby in Rails app with a non-ActiveRecord model
I'm trying to use Mobility in the Ruby in Rails app with a non-ActiveRecord model by defining a custom backend following the example mentioned here. However, despite specifying the backend in the ...
0
votes
0
answers
44
views
How to do I solve the following Assets Precompile error? [duplicate]
I am creating a ruby on rails project but my javascript files are not loading prperly.Running rails assets:clobber and then rails assets:precopile gives following error.
$ postcss ./app/assets/builds/...
0
votes
0
answers
70
views
Rails autoloader is making private constants public
I'm trying to enforce a boundary in a Rails app: only code within the namespace Boundary should be able to access the class Boundary::Blackbox.
This works alright when it's defined outside of an ...
0
votes
0
answers
75
views
Devise gem bundled but server indicating error
I am a newbie and would need some assistance. I added devise gem to my Instagram clone app and added "sign up", sign in", "sign out", and "edit profile" links onto ...
0
votes
0
answers
62
views
JSON serialization with a group by query ... how to?
I have an API endpoint to pull a big JSON blob from one of my models, and it works, but I'd like to improve it. The current implementation is below, and mostly just works using built in associations.
...
0
votes
2
answers
160
views
Rspec not able to trigger method inside after_commit callback
I am working on writing a test case for a model Benefit. The class file contains an after_commit callback which calls a method update_contract. It also has belongs_to :contract, touch: true.
@contract ...
0
votes
1
answer
90
views
Error when sending invitation with Devise_invitable
I know there's some threads about this but, from what I saw they are quite old and can probably be outdated.
I'm using devise and devise_invitable. The idea behind it is to allow admins and teachers ...
0
votes
1
answer
100
views
Getting Error - ActionController::UnknownFormat in MembersController#edit_description
Input Image
I'm encountering a "406 Not Acceptable" error in my Stimulus controller's fetch request. The controller is responsible for making an AJAX call to an endpoint, but it seems the ...
0
votes
1
answer
97
views
What each_with_object does in ruby
What each_with_object does? Where it get opts?
https://github.com/bodrovis/lokalise_manager/blob/master/lib%2Flokalise_manager%2Ftask_definitions%2Fbase.rb#L23
primary_opts = global_config
...
0
votes
0
answers
143
views
How to fix error in model with gem lockbox
I am using ruby '2.5.9' and rails '4.2.11.3'.
I configured all needed things for this gem. I have db with column "password_ciphertext", In model: "has_encrypted :password". When I ...
0
votes
1
answer
144
views
POST data then navigate to a new page and persist said data in Rails, without using the database?
I'm aware POST requests aren't meant for navigation but I just want to check if what I've been tasked with is possible.
I have a page in my Rails app - let's call it cars#index. I'm required to make ...
1
vote
2
answers
134
views
is there a way to write this clean?
So i have a flag to disable and enable a feature. and will based on the variable it has to toggle the flags
flag_a, flag_b, are my two feature flags and the variable input string can be none, all,...
0
votes
0
answers
36
views
Can we view PostgreSQL tables in django admin or in rails admin, I saw one day my QA colleague viewing tables from rails admin, was that SQL tables?
Just a question,
I am Front-end Developer, newbie Backend
I saw one day my QA colleague viewing tables from rails admin which was deployed for Backend Testing.
So was that MySQL tables, can't we do ...
1
vote
0
answers
221
views
I do not know why I get the following error:uninitialized constant Games Object.const_get(camel_cased_word) ^
I work on a Rails project and I seem to have a route or controller problem which I do not understand. This is the error I receive: uninitialized constant Games Object.const_get(camel_cased_word) ^^^^^^...
0
votes
0
answers
74
views
Execute a ruby script in scala or convert logic in scala
I have a very small ruby script that I need to run in scala either by straightway running the sript which according to resources online is possible through org.jruby but the dependency doesn't work ...
1
vote
2
answers
1k
views
Ruby Version Manager
I'm new to Ruby and currently using Windows 10. I'm facing difficulty installing RVM. Since I work on different projects with varying Ruby versions, I want to use RVM to manage them easily. Currently, ...
0
votes
0
answers
40
views
"Bundle update rails" is failing with multiple dependencies error
I'm using following configuration inside the project directory:
Ruby version ruby 3.1.4p223 (2023-03-30 revision 957bb7cb81) [i386-mingw32]
Rails version 4.2.5
Gem version 3.3.26
Bundler version 1.16....
0
votes
1
answer
55
views
How to handle the params for accepts_nested_attributes_for for has_many association containing a lot of fields on both associated table
I have user model which has has_many association with building model. Initially I was creating the user and the building seperately by using user.create and user.buildings.create because there were ...
0
votes
2
answers
81
views
How can I prevent n+1 issue from array that is generating additional conditions?
I'm facing n+1 issue when using conditions on array that comes from includes query.
Here are the following tables:
rems
|id| |name|
1 aaa
2 bbb
rem_correlatives
|id| |rem_id| |name| |deleted| |...
2
votes
1
answer
2k
views
Psych AliasesNotEnabled after upgrading Rails to latest version
I had an application running on Ruby 1.9.2 and Rails 3.0.3. I upgraded Ruby to version 3.0.0 and Rails to 7.1.2. Now when I run "rails server", I have the following error message and the ...
0
votes
1
answer
86
views
Error installing Rails 3.0.3 on Ruby 1.9.2
I have an old application that runs on a CentOS server with Ruby 1.9.2 and Rails 3.0.3.
I am trying to install my application on a new DEBIAN 10 server.
I could install Ruby 1.9.2 but when I try to ...
0
votes
1
answer
162
views
Rails both way relationship between two tables
In Ruby on Rails I'm trying to be able to create both way many-to-many relationship between two tables. I want a relationship in routes and controllers. For example I want to be able to do both of the ...
0
votes
1
answer
221
views
Is there any valid reason why gem omniauth-rails_csrf_protection in only Rails 4.2+ compatible?
I was wondering is there any valid reason why omniauth-rails_csrf_protection is not compatible with the versions of Rails below 4.2? Are there some functionalities in Rails 4.2+ that are crucial for ...
0
votes
0
answers
56
views
Getting permission denied error when downloading a html page as html
This is my shortlisted action and shortlisted.html.erb , when clicked on download the list of shortlisted candidates should get downloaded.
def shortlisted
ids= AppliedJob.shortlisted.pluck(:user_id)
...
0
votes
2
answers
84
views
How can I get the maximum value on string between a symbol?
Hi StackOverflow Community.
I have the following table with two tables "id" (integer) and "num_pot" (varchar 255) with the following data information:
|transformers|
|id| |...
-2
votes
2
answers
69
views
In my controller's update action, when update_attributes fails due to the validator, I lose the /edit suffix in my URL
Description of my work environment: Rails 4.2.4, Ruby 2.3.1, SQL Server database, javascript on object html views
My controller that content an update action:
if @cs.update_attributes(...
0
votes
1
answer
790
views
wrong number of arguments (given 2, expected 1) on = image_tag 'home1.jpg'
I'm upgrading an application from rails 4.2 to 7.0.
I've already upgrade my gems, but when I try to access to localhost it returns an error like
wrong number of arguments (given 2, expected 1)
on line
...
0
votes
1
answer
124
views
Ruby on Rails - Zip/HTTParty
I have an api request that returns multiple (Word) files to-be-downloaded, but I can't send_data IN the while loop, else I'll get the dreaded Multiple Renders error, so my question is how can I ...
0
votes
0
answers
61
views
Rails 5 - Validate devise users email based on scope of two dynamic attributes
How can I validate a users email based on some condition thereby overriding devise default VALIDATABLE feature.
Users table has company_id(has one role as owner) and institution_id(has two roles as ...
0
votes
1
answer
396
views
Change the default route from / to /docuseal/
I don’t know if it’s the good section but my problem is the following one :
In my VM, I have a django server running with gunicorn and nginx and I would like to add a docuseal entity running with ruby ...
0
votes
0
answers
107
views
Rake and Rails console throwing Postgres exception
We have a legacy Rails 4.1 application running on Ubuntu 22.04 TLS (rbenv 1.2.0, ruby 2.1.10, pg gem 4.0.1, Postgres 10) that runs correctly, but Rake (12.3.3) and Rails c (when accessing ActiveRecord ...
0
votes
1
answer
67
views
In ruby rails, is there a method to get the objects outside of a where method's scope?
For context, basically Im trying to find out which Users don't have a certain post, for example:
@specified = User.joins(:post).where(post: {content: "Goodbye!"})
vs. what I want to get (...
0
votes
1
answer
48
views
Unable to save password utilizing bcrypt-ruby and has_secure_password
We are moving from Devise to a more streamlined authentication process. If I can solve the following problem, I think I can get the rest of the authentication process working.
If one of our clients ...
0
votes
1
answer
41
views
how put an id unique in a button in a rails loop?
I have a grid where the receipts are listed with their information and the display button. The idea is that pressing the button that appears in the actions column (button_tag) sends the information of ...
-1
votes
1
answer
71
views
How to query entire table(3 tables with 100k records each) data and then display data from them in dashboard
I have 3 models, Postgresql db -
##user.rb - :full_name
has_many :enquiries
##enquiry.rb - :actual_target_count, :actual_visit_count
##there are different types of enquiry too - business, formal, ...
0
votes
1
answer
572
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 ...
2
votes
1
answer
104
views
Cache Prior .includes in ActiveRecord
I have three collections – Company, Person, and Email – a company has many people, and a person has many emails
If I do something like
company_with_emails_preloaded = Company.includes(people: [:emails]...
-1
votes
1
answer
46
views
undefined local variable or method `asistencia_params' for #<AsistenciaController:0x00000000083450>
class AsistenciaController < ApplicationController
def asistencia
@username = params[:user_username]
@entry = params[:user_entry]
if @asistencia.update(asistencia_params)
...
0
votes
2
answers
65
views
How to change the tag column selection option
I have a tag column in the active admin index page like
tag_column :result, interactive: true, sortable: false
in my model I have a enum for result as
enum result: { winner: 0, first_runner_up: 1, ...
1
vote
4
answers
71
views
ruby combine hash related key
I want to combine related key for example:
my_hash = {key_a: "value a", key_b: "value b", key_c: "value c"}
I want the result to be:
{ key:
[
{ a: "value a&...
0
votes
3
answers
51
views
How to use Joins followed by left outer join in ruby on rails?
I have the following database schema structure:
School
has_many :students
Students
has_many :books
Books
(has an attribute pages(integer))
The issue is I want a total of all the pages of a book a ...
0
votes
1
answer
112
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 ...
1
vote
1
answer
75
views
Rails 3.2 -> 4.2 Emergency upgrade, memory leak on Heroku
with the May 1st deprecation of the Heroku-18 stack, I needed to update a very old Rails app to the minumum version required. It was though, but I got it working.
I have a completely new version to ...
0
votes
1
answer
344
views
How to attach image url in seed file with rails active storage?
Recently upgraded from Rails 4 to Rails 7.0.4.3
I now get an error
Could not find or build blob: expected attachable, got #Tempfile:/var/folders/m3/5b_093ms4n7254zlxjr2fthw0000gn/T/open-uri20230418-...
0
votes
0
answers
76
views
RSpec api json recovers html instead of json
Context:
I have created a timesheet, I want to test the CRUD of it with the json api, but when I launch the test in the console it returns me an error indicating the webpacker can't find the file.
...
1
vote
2
answers
2k
views
How should I upgrade an outdated ruby on rails project?
I have a project that is currently running on rails 4~ and Ruby 2~, a lower version of it. I don't recall the exact iteration but it reached end of life about 8 years ago
For context, the original dev ...
0
votes
1
answer
64
views
How do I prevent a form from submitting if two input fields do not have the same value?
I am using the following code to check if two input fields have the same value on form submit:
$(document).on('submit', '.confirm-prescription', function(e) {
e.preventDefault();
const ...
1
vote
2
answers
763
views
Rspec fails after Rails version update
I got into a new project that hasn't been touched for a couple of years prior, the clients want me and my team to update Ruby/Rails from Rails 4 to the newest possible version without breaking the way ...
0
votes
0
answers
45
views
Running the rails console command will show the rails default help page
I have a bit of a weird situation. I'm using rbenv on my production server.
Now I wanted to access the console:
cd $HOME/rails/current
RAILS_ENV=production bundle exec rails console
Now Instead of the ...
1
vote
1
answer
109
views
Unauthorized access error from google bucket while accessing getObject API
Since past few days, our system is experiencing one strange issue. We have one ruby application in which has a sidkiq worker(a scheduled job). This worker is accessing google cloud bucket in frequent ...