Category "ruby-on-rails"

Attach one Active Storage blob to multiple files

In Rails, when attaching a file to an object, is there a way to check if it is already attached to another object? And if so, can I then use this existing attac

Stylesheet renders in grover debug but not on downloaded pdf

I'm using Grover to render and download pdf copies of documents that are generated in my app and am having trouble applying css to it. When in grover's debug m

(Rails 5) LoadError: cannot load such file -- sass ...when deploying to Heroku

I'm getting the error in the title when I deploy my Rails 5 app. I recently updated my Gemfile to include some more recent versions. I don't have any issues on

Slideshow images load on page reload Rails & OwlSlideshow

I'm facing the following problem: I'm using an external API that returns a image hash that has multiple images. When I enter the show page for the element that

Problem when creating mysql database on M1 mac: symbol not found in flat namespace '_mysql_affected_rows

I'm trying to create a db for my rails project using [email protected] which was installed via homebrew. The installation was succesfull, but when I try to run: bin/rak

PG::UndefinedTable: ERROR: relation "entries" does not exist

I'm trying to deploy a simple Rails app in heroku but I'm getting this message in the heroku logs: PG::UndefinedTable: ERROR: relation "entries" does not exist

Ruby on rails turbo current user access

index.html.erb <%= turbo_stream_from "posts" %> <%= turbo_frame_tag "posts" do %> <%= render partial:'posts/post', collection: @po

RSpec: how to chain receive().with()?

I've been writing tests with instance_doubles to stand in for message chains when I need more granularity in the midst of the chain. But, I'm wondering if I'm d

No such directory ruby.exec Errno:ENONT

I'm new to ruby on rails. I installed ruby, sqlite3, node and yarn, run gem install rails and gem install sqlite3. when I run rails new <app_name>, I got

RuntimeError - Unable to find subscription with identifier: when ios app try to send a message

I am using WebSocket for comments on a post. ios user subscribe to the comment_channel and I got confirmation that the user successfully subscribed to comment_c

creating a class object array inside another object?

I've got these three classes class Totalizavel def retorna (qnt, valor) total = qnt * valor return total end end class Venda < Tota

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: