Undefined method `name' for nil:NilClass in AddServiceNameToActiveStorageBlobs
This blog posts explains how to get rid of the Undefined method error when migration ActiveStorage from Rails 6.0 to 6.1. ...
This blog posts explains how to get rid of the Undefined method error when migration ActiveStorage from Rails 6.0 to 6.1. ...
Hitman Hitman is a web fuzzer written in Ruby for Grape APIs. You can use it to check the robustness of your parameter validations by targeting your own server. Purpose Did you ever have to create a server API but were not sure if you had covered all possible and impossible inputs? If not, users might sooner or later fill your database with invalid data and your application might break. In practice, it’s almost impossible to anticipate all possibilities of usage of your API....
Real-life programming problems are often very complex and hard to solve. One of the most important things I learned was that I had to break down a large problem into smaller, easier tasks and solve those first. This helped me check for the intended behaviour early instead of having to build a large algorithm only to find out it didn’t work after many hours of programming. A simple example for taking small steps is a program which draws a chessboard....
You probably have at least heard of or even used the Array#flatten method. It returns a flat, one-dimensional copy of the original array: > ary = [[1, 2, 3], [3, 4, 5], [4, 5, 6], [7, 8, 9]] > ary.flatten => [1, 2, 3, 3, 4, 5, 4, 5, 6, 7, 8, 9] Pretty straight-forward, but still a cool feature. But wait, there’s more awesomeness. Array#flatten takes an optional argument that sets the maximum recurstion depth of the flatten calls, making it possible to flatten an array only partially:...
Have you ever had the feeling that you were repeating yourself when writing controller code for your Rails app? You were right, because you actually did! See this example of a basic posts controller in a blog application PostsController < ActionController::Base def index @posts = Post.all end def show @post = Post.find(params[:id]) end def new @post = Post.new end def create Post.create(params[:post]) end def destroy post = Post.find(params[:id]) post.destroy end end Every controller that is tied to an ActiveRecord-model has more or less this structure....
I recently had to use a very very old Ruby version for a legacy project. I installed version 1.9.1 via RVM on my Ubuntu 13.04 machine and everything seemed to work great. Until I tried to install the Rails 2.0.2 gem, which produced the following error: /home/me/.rvm/rubies/ruby-1.9.1-p431/lib/ruby/site_ruby/1.9.1/rubygems/config_file.rb:82:in `rescue in rescue in <class:ConfigFile>': uninitialized constant Gem::ConfigFile::RbConfig (NameError) from /home/me/.rvm/rubies/ruby-1.9.1-p431/lib/ruby/site_ruby/1.9.1/rubygems/config_file.rb:64:in `rescue in <class:ConfigFile>' from /home/me/.rvm/rubies/ruby-1.9.1-p431/lib/ruby/site_ruby/1.9.1/rubygems/config_file.rb:60:in `<class:ConfigFile>' from /home/me/.rvm/rubies/ruby-1.9.1-p431/lib/ruby/site_ruby/1.9.1/rubygems/config_file.rb:36:in `<top (required)>' from /home/me/.rvm/rubies/ruby-1.9.1-p431/lib/ruby/site_ruby/1.9.1/rubygems/gem_runner.rb:9:in `require' from /home/me/....