Category "ruby-on-rails"

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 #

Rails Rake Task - Delete records by passing model name and ids as params

I am intending to write a generic rake task that allows me to destroy a model's records after taking in model name and ids as input params #lib/tasks/import.r

Mysql2 error in starting rails server in mac m1

I have installed mysql2 in mac m1 using the below command gem uninstall mysql2 gem install mysql2 -v '0.3.21' -- --srcdir=/usr/local/Cellar/mysql/8.0.28_1/bin/i

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

Unable to create HubSpot Contact entry using hubspot-api-client

api = ::Hubspot::Crm::Contacts::BasicApi.new api.create({firstname: 'john', lastname: 'doe', email: '[email protected]'}.to_json, auth_names: 'hapikey') The re

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

Why f.submit is not working when I try to use it?

I created a form to my User database change his password, as it follows : <%= form_for(resource, as: resource_name, url: password_path(resource_name), html:

ActiveRecord::AdapterNotSpecified: 'development' database is not configured

I'm using MacOS and I'm getting the following error when trying to run rails s or rails routes against a Ruby on Rails repo. I don't know what should be changed

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

How to implement Zurb Foundation to Rails 7?

I'm currently upgrading my rails app to 7. I was just testing it for a while then I have issues on Foundation Rails. I installed it and followed all the steps e

`env:Client` SOAP Fault with fault string `Internal Error (from client)` on Savon 2.0 SOAP request with correct params

Using Savon 2.0 to make a SOAP request, I'm getting an env:Client fault code with the fault string Internal Error (from client): D, [2020-06-09T05:37:51.323537

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

Elasticsearch::UnsupportedProductError (The client noticed that the server is not a supported distribution of Elasticsearch

Getting this error when using searchkick with elasticsearch on mac. Searchkick version: searchkick (4.5.2) $ elasticsearch --version warning: no-jdk distributio

File Attachment Management for Rails and Oracle Cloud - OCI Object storage

Looking for a RAILS solution for OCI Object Storage, we currently are using paperclip on AWS with S3. Paperclip is depreciated and Active storage has no documen

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

Rails Turbo doesn't trigger turbo:load event

The turbo:load event is not fired after a turbo visit (as the documentation says it should). It works as expected after the initial full-page load. I can catch

Trying to use select2 with Importmaps on Rails 7

I am trying to use Select2 on a new Rails 7 app and am struggling as follows: I have pinned it into my import maps and imported it like so: pin "application", p