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

Using Select2 and Ajax on Devise/Registration controller

I have a registration controller, with a user/edit page where user can update his/her profile upon registration. The user can choose among multiple dropdown menus. One of its drop down menu has more ...
0
votes
1answer
17 views

How to count total child records of a list of parent records in Rails?

I have two models: Team and Player. Players belong to Teams and Teams have_many Players. If I have an array of teams returned as current_user.teams, how can I count the total number of players on all ...
1
vote
0answers
28 views

Why is my promise not properly setting my state?

I have a React frontend that calls my Rails backend, and I'm trying to write a promise that executes on this. However, I don't understand what is wrong with the promise I've written. I can see that ...
0
votes
0answers
22 views

Can't Assign a Database Object to Another, Validation failed: Class must exist

I am seeding a database using two CSV files to create two tables, continents and emissions. continents uses a file of countries with demographic data on each country, emissions uses a file of CO2 ...
0
votes
1answer
19 views

Carrierwave error: version doesn't exist! in Rails

I´m using Carrierwave (2.0.2, 0.11.2) in Rails 5.2.3. and I´m pretty stuck with versions of uploaded images. Imagemagick is latest version,gems Carrierwave,Rmagick and Minimagick installed. ...
1
vote
1answer
26 views

Connecting Rails and Postgres containers without Docker Compose

I know that Docker Compose (compose) is a tool that among other things makes setting up interconnectivity between containers much easier, but I am trying to practice doing that without compose to see ...
0
votes
0answers
10 views

How to prevent mongoid has_many from firing a query on a new object

I have two classes, A and B class A include Mongoid::Document has_many :bs, class_name: "B" end class B include Mongoid::Document belongs_to :a end In the rails console, i type: a =...
1
vote
0answers
18 views

How to remove trix from Rails?

With rails 5.2, I was using trix-gem. After upgrade to rails 6.0, I have the following error message in the js console : trix.js:1417 Uncaught DOMException: Failed to execute 'define' on '...
1
vote
1answer
45 views

Ruby include/extend Module: a class method - Beginner

I've been reading this article on the difference between include & extend in ruby. If I have this module, I understand how the first and second methods of the module will be used in the class. ...
0
votes
1answer
34 views

Date conversion in UTC

I am working ruby on rails. In that I have a doubt in date conversion from current timezone to UTC. The date conversion function is function date_conversion(date){ out = moment(date, "DD/MM/YYYY"...
0
votes
1answer
27 views

Sidekiq crashes every few hours in docker

I am facing an issue in which sidekiq crashes every few hours in docker. Investigating the logs reveals a "TimeoutError" when sidekiq tries to connect to redis and restarting the containers does not ...
0
votes
2answers
38 views

How to handle a three way associations in RoR?

I am making a school application where a list of courses is needed for both the lecturers and the students, a list of lecturers for the students and a list of students for the lecturers. So I have ...
0
votes
0answers
31 views

Actual value vs Display value

I am worked on ruby on rails. In that i have doubt in dateTime filter, what means I need to display one date and send another date to backend for query. Display date is date which is user entered. ...
0
votes
1answer
17 views

Uncaught Error: rails-ujs has already been loaded

I am at the very beginning stage of creating a Rails app that uses React through the front-end, and I cannot get my test/setup component to load. I'm not sure where this problem is originating, or ...
1
vote
1answer
19 views

Where would be a good place to store logic for a call to a third party api, based on Ruby on Rails best practices?

I am practicing making third-party api calls using the rest-client gem. Right now, my code for making a call to a third-party api is stored in a show method in my search_controller.rb. I'm assuming it ...
0
votes
1answer
26 views

How to right include library in webpack?

I am using Rails 6 with webpack. I want to use library jquery-textcomplete, but I don't know how I must include it to application.js file. My steps: I've install jquery-textcomplete through yarn add ...
0
votes
1answer
36 views

return instance through nested iteration

For customer_favs I was able to save all the instances of a favorite for the current customer I am working with. The favorite for a customer consists of the customer id and restaurant id. With that I ...
0
votes
0answers
12 views

How to use rack-timeout to gracefully handle request time-out from user attempting large file upload

Heroku does not allow large file uploads to the server (hard 30-second timeout). I must allow users to upload files to the server. I can warn users not to try uploading large files, but model-level ...
-2
votes
0answers
22 views

Cannot access request variable

I have the following line of code: myself = ActiveRecord::Base::Client::find(client_id) And this line errors out in rails, with the following error: ActiveRecord::RecordNotFound in ...
1
vote
1answer
21 views

Cannot add instance method to a Ruby-on-Rails model

I am trying to add a new instance method to one of my models. Here is the model: # app/models/server.rb class Server < ActiveRecord::Base def self.zzz() end end Herre is the controller: ...
0
votes
2answers
17 views

Why is “bundle install” returning an error when building my docker repository?

I'm learning how to build a rails application using docker, and each time I attempt to run $ docker-compose build web I get the following error: You must use Bundler 2 or greater with this lockfile. ...
0
votes
0answers
23 views

How do I return the Nth fibonacci number [duplicate]

I'm learning Ruby and in this homework, I need to create a method to find one or more numbers of the Fibonacci sequence. I need to return the F(0) element in a Fibonacci sequence, I found some codes ...
0
votes
1answer
7 views

Heroku Push Failing Due to Possible Bundler Issues (Rails 6.0)

I just upgraded my app to Rails 6.0 and am now unable to push to Heroku. My push shows this error: remote: ! Push rejected, failed to compile Ruby app. remote: remote: ! Push failed ...
0
votes
1answer
29 views

array iteration for ruby on rails

Each favorite consists of the customer id and restaurant id. I am basically trying to iterate through all the favorites and I am trying to see if the current customer.id is equal to the customer_id of ...
0
votes
0answers
16 views

has_many scope with a condition check on a nested association

I have an account model, that has many projects, and a project model, that has many requirements One account acts as a library account, and other accounts are the user accounts. The requirement ...
1
vote
1answer
43 views

How to use flash[] to store an email

I mostly understand what flash[] does, so I don't think that's the issue, but I think I have a syntax error somewhere? Documentation and Google are not helping, and I can't find a similar question on ...
0
votes
0answers
18 views

SystemStackError (stack level too deep) RVM 1.9.3

I have an error when running the rails server SystemStackError in UsuariosController#login stack level too deep activesupport (3.1.12) lib/active_support/callbacks.rb:396 I currently have this code ...
-1
votes
1answer
34 views

ActiveRecord child can't access itself after after_save

I have the current code class NotifyBar < ActiveRecord::Base belongs_to :user_instance after_save :update_notifications def update_notifications notifier = NotificationHandler::Notifier....
0
votes
0answers
18 views

How to filter active record result based on the return value of a method?

I'm aware of the ActiveRecord scopes, which helps to add filters by applying conditions to the SQL query. My scenario is such that, I have a bit complex business logic that cannot be easily translated ...
0
votes
1answer
10 views

Test every view searching or missing translations span.translation_missing

I am developing a rails app, and I want to test every view to know if there is any missing translation. I can do it by adding assert_select "span.translation_missing", false on every view on ...
1
vote
2answers
43 views

How to create multiple links from a single array of strings Rails - Ruby

I know it might seem simple but I've tried to create multiple links from this array in Rails array = ["/uploads/content/attachment/folder/file1.pdf/file2.pdf/file3.pdf"] What I want to do is create ...
0
votes
0answers
12 views

Debugging a rails application in Minikube

I'm running a rails service inside a minikube cluster on my local machine. I like to throw breakpoints into my code in order to interact with the process. This doesn't work while inside Minikube. I ...
0
votes
1answer
25 views

Downloading all files from URL with extension filter

I want to download all files from FTP or HTTP using extension filter For example, I have one URL that contains many MKV files and I want to set the extension filtering to download all MKV files from ...
0
votes
0answers
14 views

Generating PDF from Rails Backend

I have a 'download' button on the frontend (vue.js) that's reaching the endpoint /reports in my app. In the reports_controller, I'm scoping the data that I need and then trying to create a new PDF ...
0
votes
1answer
21 views

Blocked host: localhost ruby on rails 6.0.0

I am developing my first rails 6 app but when I try to serve it in development environment behind my nginx server, I find this message I tried adding the configuration mentioned in the error in ...
0
votes
1answer
19 views

How to route navbar search to a specific index view?

I'm trying to implement a navbar search and have attempted to follow these solutions /a/19929707/5101493 and /a/52538766/5101493. Unfortunately my ...
0
votes
0answers
19 views

How to merge template and JSON with Mustache gem?

How to merge template and JSON with Mustache gem? I can't figure out whats the problem with my code. doc_controller def show # Merge template and JSON with Mustache @merged_template = ...
3
votes
1answer
25 views

IF user_signed in? CASE current_user.plan_id ELSE …?

This 'elegant' helper for showing the user/member status is working perfectly for CASE 1-3 but not working (not showing anything at ERB view <%= user_cat %>) for: user.plan_id=NULL What's the ...
0
votes
0answers
17 views

Unauthorized after logging in angular with rails backend

Hi i am creating an app with front-end in angular and back-end is ruby-on-rails. I have setup the login with doorkeeper but the problem is now i am getting is i am able to log in with valid ...
0
votes
0answers
24 views

Ruby on Rails test fails or succeeds depending on how the test suite is called

I'm working my way through the Hartl Ruby on Rails Tutorial (4th Edition) and I've come across a problem with some tests I'm trying to run - specifically the exercise in section 11.2.3. All of my ...
0
votes
0answers
10 views

Cannot Require Popper with Webpack

I'm attempting to move my javascript files to Webpack. I'm not very familiar with Webpack so I am not sure that I have coded any of this correctly. I am trying to load jquery-ui, popper, and bootstrap ...
0
votes
0answers
19 views

AWS EC2 Rails application production.rb and settings config.consider_all_requests_local does not work

I have rails 5.0 app deployed on AWS EC2 instance and It use 2 t2.medium tiers for running. My problem is I cant show error page with plain errors (see a more useful error message that includes line ...
-1
votes
2answers
55 views

How can i replace a parameter by looping parameters in ruby?

I have an array of parameters and i want to replace all parameters by looping over array in ruby on rails. I am using before_action in controller as before_action :cost_format This is an array of ...
0
votes
1answer
28 views

Heroku and ruby on rails: Deploy works, but running app fails do to usual sqlite3 error

I know that this problem is common, and a lot of questions here on S.O. presents the same solution, to install pg instead of sqlite3 and move sqlite3 under development group. I already did this. I'...
0
votes
1answer
22 views

How to modify tables of a model (without controller) from another controller?

So I have a model GeneralCourses that I want to update from a controller Courses. I want to be able to add and edit entries in the model GenralCourses. The issue I am having now is that when I want ...
2
votes
1answer
38 views

Why does using a joins and includes with find_each result in an incorrect iterating count

I have a relation like this users = User.joins(:occupation).includes(:occupation) count = 0 users.find_each do |u| count += 1 end count count doesn't return the same number as users.count It ...
0
votes
0answers
9 views

“File to import not found or unreadable: compass” error after upgrade to Rails 6

After upgrading my Rails app to Rails 6.0.0, I get this error: File to import not found or unreadable: compass On this line in my css theme: @import "compass"; In my Gemfile I use this for Compass:...
0
votes
0answers
33 views

Get value from select tag on view send to controller in var ruby and rails

please can help me. I am trying to get the values ​​of the "value" fields from my select_tag in rails and send it to the controller to use in variables to execute some commands, could help me follow ...
0
votes
0answers
19 views

User Model Setup for Pundit

I would like to know what is the best setup to make User model for Pundit. (MySQL) I want: role: admin, default_user, .. groups I find this tutorial: https://medium.com/@toddbaur/using-devise-and-...
1
vote
1answer
20 views

Rails custom URL with username

I have added this route at the bottom of routes.rb: get ':username' => 'user#show' And I have also updated the controller to use params[:username] to find the user. Now the problem is the ...