Category "ruby-on-rails"

How to get all embeds_many items in Mongoid

I'm Using Mongoid and I have two models: class User include Mongoid::Document include Mongoid::Timestamps embeds_many :tickets field :email, type: Str

bootstrap 5 on rails 6 (justify-content-center)

I am a newbie here, please avoid complex answers :) A row was created to center all of its content, it worked just fine. The form submit button and the link_to

How to order a query by translated attribute of associated model in Rails using Mobility gem

I've two associated models: class Food < ApplicationRecord extend Mobility belongs_to :food_set, inverse_of: :foods translates :name, type: :string,

Rubocop – how can I just display auto-correctable results

I would like to run Rubocop and just see auto-correctable results. The documentation (https://docs.rubocop.org/rubocop/usage/basic_usage.html) indicates this sh

How to assign an instance to a variable - .find() / .where() - and access it's values - RUBY on RAILS

account = Account.find(params[:account_id]) account_to_receive = Account.where(number_account: transaction.account_to_transfer) So I am building a bank app I wo

Warnings when upgrading application from Rails 5 to Rails 7

with a recent upgrade to rails 7.0.2 from rails 5.2, when ever i start a rails console or a rails server on dev mode i see these warnings /Users/opensource/.rvm

How to import JS files with esbuild & jsbundling-rails

I'm moving a Rails 6 app from webpack & webpacker to esbuild & jsbundling-rails I can't find any documentation on the correct way to import custom js fi

problems to run rails s on Rails 4 :S

Im trying to run s on my project in Rails 4.2.2 but i get a unexpected error :S Someone know the reason of the error? Thanks in advance This is my logs ....

Rails App Breaks with 404 Error when Last.fm API Call Returns Nothing

I wonder if anyone can help, and if the issue is specific to Last.fm (perhaps not the greatest of APIs). I've built an album search feature into my app that tak

Rails 7 Dynamic Nested Forms with hotwire/turbo frames?

I'm very new to the rails. I've started right from rails7 so there is still very little information regarding my problem. Here is what i have: app/models/cockta

Remote form refresh the page on submit

I am trying to add some ajax and work with remote forms on my rails 7 app. I added local: false but the form still rerenders the page instead of just sending a

I am trying to create a post in instagram clone in ruby and rails but it throws an error "no implicit conversion of Integer into string"

This is the Post Model class Post < ApplicationRecord mount_uploader :image, ImageUploader scope :active, -> { where active: true } end This is

Whats missing on my Ruby 'Inverse Of' relationship

I know this topic has been addressed, but I have been at this for 2 days and I'm just stuck. I know inverse of does not create a new query, so should I use anot

Ruby : Cannot load such file --ruby2d (LoadError)

I'm new to Ruby,Writing some code to make a game,so using ruby2d library. Got an error while writing some basic code. Help me out Folks. require 'ruby2d' set ba

how to update local gem's github token

I have locally installed gems with github address. When I want to update that gems with bundler, it tries to clone repository with an old access token. How can

gem install rails on git bash (for Windows)

gem install rails ERROR: Error installing rails: ERROR: Failed to build gem native extension. current directory: C:/Ruby31-x64/lib/ruby/gems/3.1.0/gems/websock

How to create a SQL date range query where the date range depends on holidays and weekends?

I would like fetch all records in Postgres that match a particular date range. The column 'date' is of type Date. Return all rows where date is tomorrow's date

Issues regarding the 'rails new' command

I am encountering issues when creating a new application on Ruby On Rails. Whenever I get create a new application on Ruby on Rails, my file was not created suc

Rails - StimulusJS: how to set target value from within setTimeout?

In my Rails-Stimulus controller, I fetch data in a loop from a function in which I've setTimeout. How do I set the target value from within the setTimeout? My f

Ruby on Rails CSRF token creation

The code to create a CSRF token in Ruby on Rails is: def mask_token(raw_token) # :doc: one_time_pad = SecureRandom.random_bytes(AUTHENTICITY_TOKEN