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

How to mock a GraphQL type in Rails engine rspec?

I'm working inside a Rails engine where I have a GraphQL type. module RailsEngine module Graph module RailsEngine module Types MyClass = GraphQL::ObjectType.define do # ...
0
votes
0answers
8 views

Safest way to override the update method of a model

I have the following model: class FacebookEngagement < ApplicationRecord end And I would like to override create (and create!),update(andupdate!`) method of it so no one can manually entry fake ...
0
votes
0answers
6 views

Rails: Rename a Binary File uploaded to API

I've seen a lot of threads that open up a file from a directory and rename it. But in my case, the user is uploading a file to a POST endpoint. I'd like to rename that file before uploading to my blob ...
0
votes
0answers
4 views

Keep seeing “Invalid single-table inheritance type” although inheritance is there

I have the following single table inheritance: class Post < ApplicationRecord has_many :taxonomies, dependent: :destroy accepts_nested_attributes_for :taxonomies end class Taxonomy < ...
0
votes
0answers
12 views

Passing one model to another model as attribute

I'm doing an application on rails where you can access restaurants and make orders from the plates they offer. What I want to do now is that have created a scaffold for a shopping cart called "Cart" ...
0
votes
0answers
12 views

How to get object for `reject_if`? [duplicate]

Rails documentations mention a reject_if here: https://api.rubyonrails.org/classes/ActiveRecord/NestedAttributes/ClassMethods.html Just wondering if there's a way to get the actual object that is ...
0
votes
2answers
15 views

How to attach an image from assets to a ruby object in rails 5

I'm trying to build a chess game, and I currently have the pieces being initialized through the game model, as so: class Game < ApplicationRecord scope :available, -> { where(...
1
vote
0answers
6 views

Rails XHR causes error: SyntaxError: JSON.parse: unexpected character at line 1 column 1 of the JSON data

I am working on a rails app and implementing a form that uploads images. I am using the XMLHttpRequest object to submit the form. When I navigate to the page and attempt to submit the form I received ...
0
votes
1answer
14 views

Convert rails STI type param to the actual class constant?

I am rails newbie. I create STI with the following class User and its class Teacher < User subclasses. It thrown an error when I fill in the user form. NameError at /users uninitialized ...
0
votes
0answers
10 views

Can two customers use same source on Stripe

I have a rails application in which stripe is implemented. However, I am getting an error in Stripe that says for security reasons you cannot directly charge a source that is already attached to a ...
0
votes
1answer
17 views

rails console OR irb find out the RAILS_VERSION of the current environment

Somewhat related to: Determine ruby version from within Rails How to find out the RAILS_VERSION from within rails console?
0
votes
0answers
19 views

Add javascript from codepen to my Rails App

I am trying to add this codepen to my rails app: https://codepen.io/amandaratio/pen/dRqjKY I have added the html to my .erb template, and put the css in app/assets/stylesheets. The issue is with the ...
0
votes
1answer
22 views

How to prevent an object from being created redundantly in a many-to-many relationship with a join

I'm building an API with Rails for a forum/chatroom. I have three models: class User < Application record has_many messages has_many :forums, through: :messages class Message < ...
0
votes
2answers
19 views

Skip saving associated object if invalid on update

I have a person table and address table like this: class Person < ApplicationRecord has_many :addresses, dependent: :destroy accepts_nested_attributes_for :addresses end class Address < ...
0
votes
0answers
23 views

Model not updated correctly on drag (Apartment + Vue + Rails 6)

Stack used: Rails 6 Gems used: Apartment, Devise, Vue, vuedraggable, acts_as_list I'm trying to create a "Trello" type app. Right now, I'm trying to implement vuedraggable. So here is my problem: ...
0
votes
1answer
16 views

Ruby on rails - find_by_sql with LIKE query issue

I need to define a scope like the following. I have used the "find_by_sql" method for this. I wanted to have the LIKE query with this. But when I construct the query like this I am getting the ...
0
votes
0answers
22 views

impossible to encrypt a password in a multi-step form with bcrypt

I'm a beginner in ruby on rails and I have a problem encrypting a password in my registration form. I installed the bcrypt gem but I don't understand why the form doesn't work... my form model : ...
0
votes
2answers
19 views

How to make rollback commit on heroku?

I commited new version my app on heroku. But it was a bad release. I got an error The page you were looking for doesn't exist. I tried heroku rollback, but the error does not disappear. I want to ...
0
votes
0answers
18 views

how can we can call rake task every 3 months [closed]

how can we can call rake task every 3 months 12:00 PM. for example 1) every 0 1 * * 6 // It would run 1:00 AM every Saturday. 2) every :monday, at: "08:00 am" //It would run 8:00 AM every Monday.
0
votes
0answers
10 views

Mac OS Catalina does not shutdown correctly if “rails server” is used

I've been using rails server with Rails 6.0.1 on Mac OS Catalina. I've noticed that if start the server (whether using Puma or unicorn), and shut it down, and try to shut down the computer, it just ...
0
votes
0answers
11 views

Library not loaded libssl.1.0.0.dylib

I was working on trying to fix a bug I was encountering in Dragonfly with my images not having a decoding delegate, and one of the solutions I found was to remove Imagemagick and then reinstall from ...
0
votes
2answers
22 views

Efficent way to select belongs_to model from another Model, in Rails 5?

I have 2 models: Contact -> has_many :messages and Message -> belongs_to :contact I want to select the last 10 contacts (as array of object, not only ids) from my messages table this is ...
1
vote
0answers
25 views

Cannot access Heroku rails console from terminal

I am working on a ruby-on rails application, trying to access the Heroku rails console for my production database. The current Gems I am using (that I think could be related) are: Bootsnap, Bootstrap, ...
0
votes
1answer
14 views

rspec failing tests with Mailer

I am getting an issue where the tests will not pass as it does not recognise user on completed_payments which is a method within the listing model. Would anyone know why this is happening? Error is: ...
0
votes
0answers
9 views

Why is rspec build failing despite all tests passing? Is “exit code 126” the cause?

I have a Rails app with Rspec test suite. All tests are passing locally. When I push to continuous integration (CircleCI), all tests are also passing. But despite all tests passing, the Rspec part ...
0
votes
0answers
26 views

docker-compose up keeps looping with ERROR — : No such file or directory @ rb_sysopen

when I start my container with docker-compose up my app eventually gets stuck and repeats itself over and over with these lines: I, [2019-12-09T15:19:35.396147 #342] INFO -- : Refreshing Gem list ...
0
votes
0answers
13 views

Ruby on Rails: ArgumentError (invalid base64)

I have updated my webapp to ruby 2.4.9p362 and Rails 5.2.4. Before the upgrade, initially the code was like : 1.1 This code generated a url with a token for the user salt = SecureRandom....
0
votes
0answers
6 views

Paperclip::Errors::NotIdentifiedByImageMagickError due to install ImageMagick version 7

This issue has been come up as today, which I have install update version from ImageMagic 6.10 legacy to 7 versions and the error came up when I upload the images on the paperclip Rails [paperclip] ...
0
votes
0answers
5 views

Add a breakline in ActiveAdmin without using para

How to add a break line in ActiveAdmin without using para? Having something like that: panel 'Order' do order.id br order.price end Instead of panel 'Order' do para order.id para order....
0
votes
0answers
11 views

How to use url helper in mailer? [duplicate]

I try to make email verification. I use url helper in email: <%= confirm_email_author_url(@author.confirm_token) %> But i get error: Missing host to link to! Please provide the :host ...
0
votes
0answers
28 views

Rails route does not hit unsubscribe controller action

I followed these instructions, but now I'm running into a problem. When I click my unsubscribe_url in the email, I get the following error: No route matches [GET] "/newsletter_subscriptions/...
0
votes
0answers
15 views

Webpacker fails to compile within Dockerized Rails App

So I'm working on dockerizing a rails application that's utilizing webpacker. I'm able to get the application to load except webpacker fails to compile. Versions ruby 2.4.2 rails 5.2.2 webpacker 4.0....
2
votes
2answers
39 views

ruby void value expression

why I am getting void value expression error? Code [return 1] And error from rib: SyntaxError ((irb):3: void value expression) same situation here: def a [ return 1 if true 2 ] end
0
votes
0answers
7 views

RSpec/SCIM filter implementation

I'm testing the compliance of my SCIM implementation (espacially compliance with Azure Active Directory). 2 out of my 73 tests fail. According to Microsoft documentation about the SCIM ...
0
votes
1answer
18 views

How to format jbuilder value

I got a jbuilder response like below { "name": "amb_devcernerpowerchart_com:patient_val2", "value": "{\"value\"=>\"patient_value\", \"expiration\"=>31536000, \"created_datetime\"=>\"2019-...
-2
votes
1answer
38 views

Rails create method [closed]

I am very new to rails and I am working on a project. I am working on a code written by my seniors but I have difficult time getting it all. So could any one explain me how things are working in this ...
-1
votes
0answers
14 views

Upload multiple files using Active storage

I have a json field which contains multiple keys store :sample_json_column, accessors: [:key1, :key2, key3....], coder: JSON I have used Active storage for storing images. Here Each key i mean key1,...
-1
votes
2answers
27 views

Rails ActiveRecord equivalent of Laravel ORM `attach()` method for polymorphic has_many :through

I'm transitioning from "Laravel ORM" to "Rails Active Record" and I couldn't find how do you do something like this: $this->people()->attach($person['id'], ['role' => $role]); Explanation ...
0
votes
0answers
28 views

No route matches [GET] “/admin/orders/197/update” [closed]

orders.rb if order.payment_status == 'Paid' && order.received_by_admin != 'true' link_to "Payment Not Recieved", "orders/#{order.id}/update?payment_status=paid" , class: "member_link" ...
0
votes
0answers
15 views

Gem 'mysql2' with specified version requirements is not available in SDK 'rbenv: 2.4.4'

I have this problem when I use rake db:create. Gem 'mysql2' with specified version requirements is not available in SDK 'rbenv: 2.4.4' My Ruby version is: 2.6.5 and my Rails version is: 5.1.7 ?
0
votes
0answers
12 views

how to stub a post request with the required response in rails minitest

I am trying to stub a post request with the below response { 'data' => { 'detections' => [ [{ 'language' => 'en', 'isReliable' => false, '...
0
votes
1answer
24 views

Devise destroy user create bug in index page

I got a problem with my website in local when I delete an User with Devise on rails. The user is correctly deleted but now, when I go on the event index page, with normally a list of all the event, I ...
0
votes
1answer
16 views

PgBouncer in Ruby on Rails app and advisory locks

I've been using advisory locks extensively in multiple apps and now, am looking into introducing a connection pooler due to the huge number of DB connections. I'm considering pgbouncer with ...
0
votes
1answer
25 views

How to convert mysql query to ruby on rails active record in multiple joins

I would like to ask some help from ruby on rails expert to convert this MySQL query to active record in rails. SELECT products.id, products.product_name, products.price, IFNULL(...
0
votes
1answer
22 views

AWS Error: 'production' database is not configured [closed]

I trying to deploy my app on AWS with remote mysql server but I have this error when I trying to Oper rails c or do rake db. This is nginx error: App 14089 output: Error: The application encountered ...
1
vote
0answers
26 views

Ruby on Rails Iteration of two tables, loading id

learning Rails I encountered a problem. I don't know how to encrypt two tables and how to read the service ID. First problem. I would like to display the average of service / service ratings (rating....
0
votes
1answer
25 views

Search POstgres JSONB column based on key

I have a table abcs with denom_qty jsonb column. The value stored will be in the format {"100"=>5, "1000"=>2} I want to filter all the rows where the denom_qty colum has key >= a given value ...
0
votes
2answers
25 views

Rails update params conditionally

Given an update action in controller as: def update_all_item_locations @item.item_locations.update_all( pricesell: params[:pricesell], pricebuy: params[:pricebuy], purchased: ...
1
vote
1answer
16 views

Enum, how to display multiple word in simple_form?

I'm using enum for :discount_type. The enum is either percent or price. For clarity purposes I would like to show price per day in my simple_form for the enum price. How can I do this? Code model ...
-5
votes
0answers
26 views

Ajax request not going in rails [closed]

Can someone help me that what all I have to do to make ajax request in rails