Category "ruby"

Best practice for similar repeated queries using ActiveRecord

I have a couple simple queries and I'm not sure what the best practice is. I've written them in 2 ways which produce the same result. Which is preferred? Or i

How to use format js in rails 7?

I'm using gem stripe in rails 7 and I'd like to access the checkout page to make the payments or cancel the order, however, since it is rails 7 (and does not ha

Fasterer yields "Calling argumentless methods within blocks is slower than using symbol to proc" within my validations. How to solve it?

I am coding my own ERP. For the People (model class) I have the following validations: class People < ApplicationRecord # some code for N:M relations #

ActionDispatch::Cookies not setting Set-Cookie header in response but response.set_cookie does

I have a Rails 5 API only app and want to send cookies in the response of a JSON request. When I use ActionDispatch::Cookies to set a cookie in the response of

Deployed wrong app to Google Cloud, how to prevent?

When I run gcloud app deploy I get the message: ERROR: (gcloud.app.deploy) The required property [project] is not currently set. You may set it for your current

Create a QR generator API for Ruby (2.2.2) on Rails

I have a main Ruby on Rails app, which generates links and associated PDF files. What I want is to generate a QR code for each one of the links, so I can paste

Attribute not selected on edit page

I have Projects model: class Project < ApplicationRecord acts_as_tenant :account has_rich_text :description validates :name, :progress, :priority, :st

Options_from_collection_for_select - NoMethodError Or ArgumentError - how add properly argument?

In Rails console when I write Something like: City.human_attribute_name("model") it's work correctly, a return value, but when I try to use it in .haml in Optio

Parse quoted-printable encoding content from .mht file

I am trying to get all the images from .mht file by using Nokogiri gem. But since the .mht file has quoted-printable encoding, all the images that I received, h

Rails couldn't infer whether you are using multiple databases from your database.yml in rails - 6 using nginx

While deploying code using capistrano gem - Rails couldn't infer whether you are using multiple databases from your database.yml and can't generate the tasks fo

Rails Devise - changing minimum password length for a particular user model

Is it possible to have a different devise config for a specific model? I want to have the minimum password length for all user models set to 8 characters, But f

Any workaround for solidus_braintree gem support on solidus 3.1.5(latest version) other than solidus_paypal_braintree gem integration?

I am trying to upgrade solidus_core to 3.1.5 (lates version till date) causing issue with solidus_braintree as this gem is deprecated on arrival of solidus_payp

How to extract all words of a camel cased string with a regular expression?

Assume I have a string that consists of multiple words. These words aren't separated by spaces, but every word starts with a capital letter. This type of naming

Devise, OmniAuth with Facebook, 'Not found. Authentication passthru'

I'm trying to use Omniauth with Facebook for a project but whenever I try to log in with Facebook I get a blank page with just "Not found. Authentication passth

How to dynamically inject permission checking logic for RAILS_API method

The current project adopts the front-end and back-end separation architecture, the front-end is realized by VUE, and the back-end adopts RAILS. Now we need to s

Export ipa file fails

Using Xcode v11.3 I try to export my .IPA file and get this error. An error occurred during export. The data couldn’t be read because of it isn&rsqu

Deploy via capistrano fail: "sudo: /bin/systemctl: command not found"

Now I'm transferring my environment following the below. Environment PreviousVersion NewVersion Rails 5.1.2 7.0.0 Ruby 2.4.1 3.0.0 capistrano 3.10.1 3.16.0 cap

Can't continue deploying after for while via capistrano

My environment is following the below. Environment Version Rails 7.0.0 Ruby 3.0.0 capistrano 3.16.0 Production environment Amazon EC2 Linux After for while fr

openid-connect client in ruby with example code

I want to read data from an API which requires authorization with openid-connect. My client should be written in ruby, so I can use it in a task to import data

How to use Simple Form and Direct Upload ActiveStorage

I'm having a trouble when I try to use Simple Form gem for upload video. I'm using ActiveStorage and local storage for this. My form looks like this: = simple_