How to generate controller/models/views inside lib folder? (Ruby on Rails)
I'm kind of new to ruby and I encountered this problem.rails generate model whatever creates some files inside the /app/models/ folder. But what if I want to generate those inside lib for example in...
View ArticleWhy would an active record value be inconsistent with the value it refers to...
To simplify the problem, here's the general flow of the codelet(:teacher) { create(:teacher)}context 'some context' let(:subject) { create(:subject, name: 'Math', teacher: teacher)}When I query...
View ArticleHow to use x-www-form-urlencoded in rails
Am trying to access the token from ExactOnlineAPI but the documentation recommends to only use x-www-form-urlencoded. Does Ruby on Rails has this kind of encoding, if so how can i use it.What is the...
View ArticleDry-validation how to allow array of hashes with nil value
This is how I'm trying to allow a nil value for an array of hashes (I'm using dry-validations gem)required(:properties).maybe(:array).each(:hash)This is raising the following exception:NoMethodError:...
View Articlecan't modify frozen Module (FrozenError)
locally the app seems to be working fine, I can start the server and the app loads correctly, however, when I deploy to a remote environment I get 500 error, then looking at the logs I see this error...
View ArticleHow to call "unpack" on a string in ruby C-api?
I am trying to use the ruby C-api to call unpack on a ruby string.Here is my current code:#include "ruby.h"#include <stdio.h>#include <unistd.h>VALUE dangerous_func(unsigned char* buf) {...
View ArticleJekyll ERROR Errno::ECONNRESET: Connection reset by peer @ io_fillbuf - fd:17
I'm getting the following error in my console logs when running the bundle exec jekyll command.[2020-01-29 15:34:01] ERROR Errno::ECONNRESET: Connection reset by peer @ io_fillbuf - fd:16...
View ArticleError while installing ruby on rails on windows 11
I'm trying to install Ruby on Rails, but when I run the command "gem install rails", PowerShell throws this error:C:\Users\milos>gem install railsUsing rubygems directory:...
View ArticleInstalling mysql2 gem for Ruby on Rails with Mac OSX 10.6
I am having a problem installing the mysql2 gem.This comes up when I do gem install mysql2:Marks-MacBook-Pro:~ Mark$ gem install mysql2Building native extensions. This could take a while...ERROR: Error...
View ArticleEventSource / Server-Sent Events through Nginx
On server-side using Sinatra with a stream block.get '/stream', :provides => 'text/event-stream' do stream :keep_open do |out| connections << out out.callback { connections.delete(out) }...
View ArticleTesting hash contents using RSpec
I have a test like so:it "should not indicate backwards jumps if the checker position is not a king" do board = Board.new game_board = board.create_test_board board.add_checker(game_board, :red, 3, 3)...
View ArticleRuby's Net::SSH is limited to 3 authentication tries while OpenSSH client is not
I'm having a really weird problem where when I connect to an SSH server (that has a pretty standard default configuration, including a default MaxAuthTries of 6) using Net::SSH, the connection fails...
View ArticleHow can I check if a string ends with a particular substring in Liquid?
I know there is a contains keyword so I can use:{% if some_string contains sub_string %}<!-- do_something -->{% ... %}But how can I check if a string ends with a particular substring?I've tried...
View ArticleCan Anemone crawl html files stored locally on my hard drive?
I'm hoping to scrape together several tens of thousand pages of government data (in several thousand folders) that are online and put it all into a single file. To speed up the process, I figured I'd...
View ArticleYour Ruby version is 2.6.10, but your Gemfile specified 3.3.0
I've gone through all of the fixes for this. I do not/nor have I ever had ruby 2.6.10 installed on this machine. I'm not sure where this came from. I tried regressing to ruby 3.2.0 for something but...
View ArticleRails: problem with handle redirect with turbo_stream in apps
In the application, when creating a feature, it was necessary to add hotwired/turbo-rails.// app/javascript/application.jsimport "@hotwired/turbo-rails"import "controllers"import "trix"import...
View ArticleCreate Random Integer Based on Id in Ruby
I have a scenario where I need to generate 4 digit confirmation codes for individual orders. I don't want to just do random codes due to the off chance that two exact codes would be generated near the...
View ArticleHow does rails rack-attack throttle work?
Say I have a throttle like this:throttle('emails/ip', :limit => 5, :period => 24.hours) do |req| if req.path == '/users/check_email_availability'&& req.post? req.ip endendWhat happens if...
View ArticleWhy Tailwind CSS doesn't works with public/*.html files in my Ruby on Rails...
I'm using Tailwind CSS for my Ruby on Rails project, the CSS works fine with all the layouts in views but it doesn't works with public/*.html files in my project.I have a 404.html page and a 500.html...
View ArticleCaller/Backtrace beyond a thread
As far as I know, it is possible to get only the portion of the caller/backtrace information that is within the current thread; anything prior to that (in the thread that created the current thread) is...
View Article