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.

0
votes
0answers
4 views

Send emails to multiple users at once in rails

We are transferring from old system to new system. What I want is admin can send invitation_email to first 200 parents by clicking on the send invite button and once the invite is sent then on ...
0
votes
0answers
10 views

502 Bad Gateway error on Rails app deployed on digitalocean vps with nginx/puma in production only

I have a digitalocean droplet, setup with one-click-app for rails configuration i.e. pre-configured with Ubuntu18/nginx/puma/rails. I have a very simple app that I can deploy in development ...
0
votes
0answers
11 views

No “for” on labels with form_with

I have a very basic form: <%= form_with model: @program, url: program_path, method: :put do |f| %> <%= f.check_box :new_model %> <%= f.label :new_model, 'my label'%> <% end %&...
0
votes
0answers
11 views

Partial rendering based on condition and sourced from different array

A somewhat complex action assembles two set of arrays into a single one. @packages = (@packageoffers + @availables).sort_by(&:cost).paginate :page => params[:page], :per_page => 20 The ...
0
votes
1answer
21 views

undefined local variable or method `api' for main:Object (NameError)

Hi guys i'm new on RoR and have question, i'm getting this error on my Terminal when i'm trying to run > ruby api_controller.rb undefined local variable or method `api' for main:Object (NameError) ...
0
votes
0answers
17 views

Postgres search for date that can return 2-6-1992 on searching 2/6/1992

I have text type search field where user can write anything i.e. ID, Name or Date I am generating sql for search, which is working fine. But for date it is selecting record having date_of_birth: 02-...
0
votes
0answers
9 views

In Rails 5.2 how can I configure my system tests to use a selenium remote server?

My current development setup is using Windows 10 with WSL (Windows Subsystem for Linux) and Rails 5.2 app. I've been attempting for days to get my system tests to execute and I believe I've ...
0
votes
2answers
28 views

How to make my DB query method in Rails more efficient

I am doing a query over my POSTGRESQL DB. My app has Articles and the Articles can have a number of Hashtags. Those relations are saved in a joined table of Hashtags and Articles. I have a working ...
0
votes
0answers
9 views

rails 5 algolia search - filter results by user status

I'm trying to filter search results displayed using the algolia gem depending on whether the current user carries 'admin' status or not. All users can create customers, but 'admin' users have access ...
0
votes
1answer
21 views

Rails: ActiveRecord::RecordNotFound Couldn't find Photo without an ID

I have two models, Services and Photos. Under service model belongs_to :user and has_many :photos and has_many_attached :images. Under photo model belongs_to :service Under the Photos viewer I'm ...
-3
votes
0answers
12 views

how we can create cart cartitem order and orderitem table for shopping website

I have two tables cart and cartitem but two more tables i want to create i'm in confuse about relation about these 4 tables Cart(id: integer, user_id: integer, created_at: datetime, updated_at: ...
0
votes
0answers
20 views

link_to_add_association adding two partials instead of one

When I click on "Add User", two rows are added instead of one. See it here new.html.slim : = page_header = simple_form_for @instance, url: admin_instance_users_path, method: :post do |f| = f....
-2
votes
0answers
23 views

Errno::ECONNRESET: Connection reset by peer - SSL_connect

I am getting this error: /usr/local/lib/ruby/2.4.0/net/imap.rb:1490:in connect' /usr/local/lib/ruby/2.4.0/net/imap.rb:1490:instart_tls_session' /usr/local/lib/ruby/2.4.0/net/imap.rb:1083:in initialize'...
0
votes
0answers
14 views

how to access specific ActiveStorage image in multiple images

I am using ActiveStorage for Ruby on Rails project. A post has many images and I want to use the one of images with headline. I am wondering how to access specific image in multiple images. Current ...
0
votes
0answers
14 views

Upgrade from Rails 4 to 5 logs in Kibana only for API namespace

My Rails 5 upgrade attempt is on Staging but I can't find any logs in Kibana since the deploy for requests (client/admin interfaces) other than direct API requests. I updated the lograge gem but the ...
0
votes
1answer
30 views

Call and execute rails method only on click

javascript function: document.getElementById("pause").addEventListener("click", function(event){ event.preventDefault(); <% execution.pause %> }); pause button: <%= button_tag(id:'...
0
votes
1answer
27 views

ruby on rails - User profil page with devise - routing to show profil page

Hi I'm facing a bug when I try to implement a link_to my profile page on my navbar. it show me a routing error with the missing key id, it only appear when I put the link on my navbar, otherwise I can ...
0
votes
0answers
27 views

How to profile a controller action with Rails?

I have a controller action which renders some JSON with the help of a service class, something like: def index render json: ServiceClass.search(params) end The ServiceClass's .search method is of ...
0
votes
2answers
15 views

actiondispatch cookieoverflow post request

I have a form in which I add custom html in body of form(By JS). When I add like 20 objects(3 input fields in a row), I get rails error i.e. ActionDispatch::Cookies::CookieOverflow It occur ...
0
votes
0answers
8 views

Rails lograge missing loglevel at service levels

After adding lograge, I can see log levels for requests. However when it's used at service layer, it doesn't give me the log levels. An example is below. [433a6cd6-f648-4f69-330b-999c3d410bd0] ...
0
votes
0answers
28 views

Validate uniqueness still blocking after a delete_all command

I have a rails model with a constraint on 2 keys validates :worker, uniqueness: { scope: :job } I deleted all entries for this model with a Model.delete_all But when I try to add a new entity ...
1
vote
0answers
31 views

Simulating a Timeout in RSpec?

I’m writing regression tests for a part of a Rails application that looks like this: Timeout.timeout(mode == :index ? 6 : 45) do imap = Net::IMAP.new(...) end I want to verify that in each case (i....
0
votes
0answers
22 views

Can a has_and_belongs_to_many association include an "owner'?

So in my case, I have a Project and Client model, and they have a have_and_belongs_to_many association between each other, as shown below: # app/models/client.rb class Client < ApplicationRecord ...
1
vote
0answers
21 views

Can the papertrail gem insert audits in async?

I want to track changes to my models but I don't want to slow down my app by introducing more db calls. I wish to save audits in another database in async. Is it possible in Papertrail?
0
votes
0answers
18 views

Can we use puma-dev to simulate a different domain other than .dev or .test

At the moment I am able to run example.dev but I would like to have to use example.com.au on with puma-dev. I didn't find much luck with goole. Would appreciate any direction.
0
votes
0answers
25 views

Rails grouped_collection_select not working when saving

I'm using grouped_collection_select in filtering out associated information in a rails 5 form. The first grouped_collection_select works with the Property filtering out associated data relevant to Co-...
0
votes
2answers
40 views

Rails 5, can't use request in controller?

Want to use request.host_with_port in controller, but not effect. class SomeController < ApplicationController domain = request.host_with_port ... Got error: NameError - undefined local ...
1
vote
0answers
26 views

How to remove certain radius from a given polygon

I am using Ruby on rails with mongodb. I have saved the boundary of a state polygon inside mongodb, Now i have got some certain latitudes and longitudes, I have to query mongodb where 1KM radius ...
0
votes
3answers
38 views

How to read the CSV based on encoding in Ruby on Rails

I used https://github.com/roo-rb/roo to parse the CSV file in Ruby on Rails. Code is following as data = Roo::CSV.new(obj.public_url, csv_options: {encoding: Encoding::ISO_8859_1}) There is an issue ...
0
votes
3answers
36 views

How to push extra text to 'select' label in Ruby on Rails

I have a select_field on a form such as: <%= f.select(:task_id, Task.all.collect {|p| [p.name, p.id]}, {prompt: "Select"}, {class: 'form-control', required: true}) %> The generated HTML is: &...
-3
votes
2answers
51 views

Rails: Having trouble running Rails console

I'm having a lot of trouble trying to get my rails console to work properly. This is a new macbook pro that I migrated, if that matters. I ran bundle and bundle update already... Versions: Rails ...
0
votes
1answer
26 views

Ruby Mixin module not saving Active Record property

I have a eBook resource with a value property: class EBook < ApplicationRecord include Mixin end and a module: module Mixin extend ActiveSupport::Concern included do # validations ...
0
votes
0answers
37 views

`Rails Server` gives error that it can't find 'railties'?

I'm new to Ruby and Rails and have been trying to get it installed on my computer properly for the past 3 days. Whenever I run rails server I get: rails server Traceback (most recent call last): ...
0
votes
0answers
20 views

Rails copy part of a remote file

I'm trying to develop a software that for each function it opens an SSH connection to my remote server and copies part of my production.log file, this must receive the 100 last rows of my file, I'd ...
0
votes
1answer
20 views

Rails 5, Capistrano 3 how to clear cache after deploy

I want to execute the cap equivalent of Rails.cache.clear after deploy, but cannot get it to work. Here's my attempt in the deploy.rb file namespace :deploy do after :restart, :clear_cache do ...
1
vote
1answer
20 views

Ruby on Rails & Redis: uninitialized constant Redis::Namespace

I was messing around with the routes and decided to restart rails server and I ended up getting this error. I am using ruby on rails 5 with rails server 2.8.4. I tried running bundle update to see if ...
1
vote
0answers
21 views

Rails 4.2 & Postgres: database migration changes schema.rb - null: false removed from timestamps

I followed the setup instructions for a Rails project I've been handed to work on. However, after creating the database and running migrations with bundle exec, the db/schema.rb changes. The main ...
0
votes
2answers
35 views

How to return an object from a sample data in model

I am playing with sample data. I don't have any data in database at this moment. { "Name": "john", "ProductIds: [1, 2, 3], "Products": [ { "description": [ { ...
0
votes
1answer
25 views

Rails - stringify_key error when attempting to change a value

I have a button that changes a boolean value to deactivate an object rather than delete it. It works, however when I attempt to apply styling to it, I get the following error: undefined method `...
0
votes
2answers
18 views

Stuck trying to build nested commenting system Rails 5

Unsure what to do at this point, I've followed a tutorial but can't get even the comments to post currently. They work just fine if I take all relations/mentions of commentable out of the models. ...
0
votes
3answers
26 views

docker-compose error connecting to redis + sidekiq

I am trying to build a container with docker but I cannot connect sidekiq + redis, the error says sidekiq_1 | Error connecting to Redis on 127.0.0.1:6379 (Errno::ECONNREFUSED), seems to sidekiq is ...
0
votes
2answers
35 views

Why does schema.rb update after I run db:migrate for Rails?

My understanding is that whoever created the migrations should've also updated schema.rb. Since I've pulled the migrations, I should've also pulled the updated schema.rb. However, once in a while, ...
0
votes
1answer
17 views

Rails 5 way to handle ActionController::ParameterMissing

If a parameter that's required is missing using strong parameters, the Rails server will respond with an HTTP 500. This does not give me control over giving the user feedback with what exactly went ...
0
votes
1answer
35 views

How To Set table value to true when admin presses submit

I have a commenting system on my website and want to add an admin signature to comments made by an admin. I know I could just set up a checkbox that is only visible by current_user.admin? through ...
0
votes
1answer
14 views

Manual uploads using Active Storage with JSON

I am trying to make a general files uploader for all the files and images for my Rails app. The uploader function is the same like the popular JS uploaders such as Filestack or Uppy Uploader, where ...
0
votes
0answers
20 views

Rails server fails to load gems on startup

So I'm trying to resurrect an old rails application and hitting a hard roadblock. The previous maintainers are MIA and a skeleton README is the only tool I have in my arsenal. The app uses haml ...
0
votes
1answer
35 views

Displaying has_many through association in rails

I have a small app that allows the user to track their holdings for a portfolio by adding their own stock picks to it. I have built the associations to be the following: stock.rb has_many :...
0
votes
0answers
26 views

Unpermitted parameters: offices in a has_many :through association in Rails 5

I have a has_many through association. When I go to the Store form I need to save Owner data in the same form. But I keep getting Unpermitted parameters: :offices. I tried with inverse_of as well. I ...
0
votes
1answer
18 views

RSpec Testing Rails Dates formatted with MomentJS

We've have a curious (timezone?) problem around the testing of Date/Time in a Rails application. The date being tested is created_at on a Rails object. On the front end (.html.slim page with some ...
0
votes
0answers
15 views

ruby nokorigi export csv columns

i want to export csv in 3 columns with the type of it but the result that i get is not the same what i want. it's just only one column to show all my data, please help me what should i do require '...