Category "ruby-on-rails"

"Undefined method `build'" when using Rspec + FactoryBotRails

I'm trying this gem called FactoryBotRails. For some reason, when I try it on one of my models unit tests, the following error is thrown. Failure/Error: my_

Mysql2::Client::LONG_PASSWORD (NameError)

I am trying to upgrade my ruby version from 2.4.5 to 2.4.9 in my rails app in Docker. After rebuilding my container it stops with the error: uninitialized co

What is the correct way to update images with has_many_attached in Rails 6

I have a Rails 6 app that uses Active Storage to store multiple images to a model (Activity) with has_many_attached. I don't understand how to append extra im

What is the correct way to update images with has_many_attached in Rails 6

I have a Rails 6 app that uses Active Storage to store multiple images to a model (Activity) with has_many_attached. I don't understand how to append extra im

Ruby / Pundit -> user.owner_of?

I saw below in the pundit documentation and was wondering if that is part of some ruby or pundit magic based on user_id being present in a given model. Or if it

Find records with missing associated records in Rails

I have a legacy database where I have two models as: class Purchase belongs_to :product end class Product has_many :purchases end Now over time some of

Devise Invitable: Return a list of invitation tokens

I'm trying to add a button to my page that exports a list of the invited users with Devise Invitable. I want to include the invitation_tokens in that list. User

Rails—get a random record from db?

To get a single random record from the db, I'm currently doing: User.all.sample But when there are 100000+ users, it takes a few seconds to load them all, jus

Ruby on Rails // Getting a Strange Return on .each loop

I am making a shopping cart for a web app. So far it has 3 components: 'products', 'line_items' and 'carts'. The flow seems to be okay. I am getting all the

No route matches [GET] "/packs/js/application.js"

I get an error when trying to reference the javascript packs in my code. Any thoughts on what I might be missing? application.js import Rails from "@rails/ujs"

Rails server stopped running after omniauth update (breaks devise)

I followed the pull request from the branch to the master (devise) but I'm still having the error and I can't deploy the api to the server anymore I also tried

Rails has_many through has_and_belongs_to_many

I am trying to find way to get data from a has_and_belongs_to_many association through a secondary model. I'll say sorry now as I might not explain this right,

Issues regarding new Ruby On Rails Application

I attempted to make a new app using rails new command and the bundle is completed. However, it said that rails aborted! and appeared another error: Bundle compl

failed to build rails server cause of tzinfo

i already add gem 'tzinfo-data' on my gemfile but its keep saying please add tzinfo-data when I make rails server. Is it because of the rails that I install or

How to get latest version of Jquery through Jquery-rails in rails application

I am trying to fix the CVE's related to jquery as follows. So for that I am trying to consume latest version of jquery. Earlier I had //= require jquery in ap

Rails: How can I test for the presence of ¡ in mailer text?

I'm trying to rewrite an rspec mailer test and I cannot figure out how to account for the special character ¡ in this text: <p> You have been add

Spree -4.4 - Fresh install gives sprocket error re: spree-dashboard.js

Im facing missing 'spree-dashboard.js' file not found on fresh spree 4.4. Its not fixed by runing yarn install.

tailwind.css not being generated in a Rails 7 project in Heroku

I have a Rails 7 project using TailwindCSS deployed to Heroku that is not building tailwind.css during rake asset:precompile and I don't know why. When I try to

Reasons why Letter_opener would not work anymore?

I have a Rails project and i'm working on 2 computers ( MacBook and Imac ). Suddenly letter_opener stopped to work on MacBook. I recently updated both computers

Rspec Capybara Failure/Error: DatabaseCleaner.clean

I am using rails 6.1.4 (Ubuntu 20.04) and am running tests with rspec, factorybot, and capybara. I also got database_cleaner where I'm using :truncation to star