Category "ruby"

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,

Microsoft OAuth parsing state parameter as string, but return a hash

I'm using the Microsoft identity platform and OAuth 2.0 authorization code flow to authorize user information from Microsoft Azure. In my Ruby code I parse the

Mysql2 connection in ruby always take my Ip address to connect and ignores the value in host

I am trying to connect to my database through mysql2 in ruby with the following: client = Mysql2::Client.new(:host => host, :username => username, :passw

Difference between bin and exe when creating a gem

I'm creating a gem for the first time and I'm a bit confused by the bin/ and exe/ directories. I've added an executable to spec.executables with: spec.bindir

Devise forgot password renders wrong template

Rails 6, Devise 4.7.3 I have a forgotten password template in my views as users/passwords/new.html.erb that renders fine, collects an email, and sends that ba

How do a rename a file using the Google Drive API for Ruby?

This seems like a basic question, but I'm well into my second day now :( I'm using the Google Drive Ruby Api here: https://github.com/google/google-api-ruby-cl

Git Bash on Windows with Ruby: Waiting for gets() input before printing prompt?

I'm new to programming/Ruby and can't figure out this quirky issue... Running this Ruby code through Git Bash on Windows: $ ruby test.rb puts "Give me input:

Unable to run Puma as daemon OptionParser::AmbiguousOption: ambiguous option: -d

I upgraded to Puma 5.0.2 and started my rails app as usual with: bundle exec puma -d -e production -b unix:///home/user/app/tmp/puma.sock Now I get the error:

Rails ActiveRecord migration to add foreign key with 'NOT VALID' parameter

Can add_foreign_key add a 'NOT VALID' parameter to the ALTER TABLE command? (Postgres, if it mattters) I have a foreign key between two very large tables. I ne

Your bundle is locked to ffi (1.11.0), but that version could not be found in any of the sources listed in your Gemfile

I get this error when starting the rails server: I've tried gem install, gem update, bundle update, bundle install. Your bundle is locked to ffi (1.11.0), but

Call Private methods outside class definition

I'm trying to use a Gem that provides me with a DSL i need to apply on some of my classes. But using it directly makes my class definitions not as clean as i wa

rails server not running exiting

This is the output I have obtained when run rails server. I am new to ROR and the version is 3.1.0. Any help would be appreciated I am running this in windows 1

Force Jekyll to re-read files in a collection to _site after a Hook runs

I've written a Hook for my Jekyll site that takes a .json file from my _data directory, creates a bunch of .md files from it's content and stores them in a _col

Breakpoint not working on VScode for Rspec Rails

Not sure what's wrong with my setup. I've been stuck on this issue for a day now and still hasn't resolved this. I've setup my VScode so I can debug my specs (f

libffi.so.8: cannot open shared object file

I upgraded Rails to 7.0.1. When I do the rails g controller Pages home, it's giving the error: >>rails g controller Pages home /home/shadman/.rbenv/versio

How to use Unicode chars with Nokogiri::XML::DocumentFragment

I want to use Unicode char with Nokogiri::XML::DocumentFragment. frag = Nokogiri::XML::DocumentFragment.parse("<foo>ü</foo>") => <foo>

How to remove an element from a json with ruby?

For this json structs: { "a_path": { "b_path": [ { "id": 1, "name": "a" }, { "id": 2, "name": "b"

Every error in the book from google-api-ruby-client but no data

I have been attempting to work on a request from my boss this week that requires using the google admin directory api. At this point I am questioning if what I

What is the return value of update_all() in ActiveRecord / Ruby on Rails?

The Ruby on Rails and ActiveRecord documentation, Google, and StackOverflow are conspiratorially silent on the return value of update_all() What does update_al

Uninitialized constant User::ChatRoom

I get this error NameError (uninitialized constant User::ChatRoom): app/controllers/users_controller.rb:20:in `create' Here is my user.rb file class User in