ruby-2.3 Questions
4
I created a new migration, it looks like this one:
class AddCommentsToUsers < ActiveRecord::Migration
def change
add_column :users, :comments, :text
end
end
Now with Code Climate I am warn...
Livelihood asked 9/5, 2016 at 18:27
7
h = {
data: {
user: {
value: "John Doe"
}
}
}
To assign value to the nested hash, we can use
h[:data][:user][:value] = "Bob"
However if any part in the middle is missing, it will cause e...
Arsonist asked 5/1, 2016 at 20:16
9
I recently updated my system to Ubuntu 18.04 LTS, and since then, the Ruby version seems to have updated to 2.5. The issue is that, when attempting to deploy a project that uses Capistrano, it will...
Tolliver asked 29/4, 2018 at 9:43
3
Solved
Error
Error running 'env GEM_HOME=/Users/john/.rvm/gems/ruby-2.3.8@global
I encountered this error while I was trying to install ruby 2.3.8 in MacOs Catalina 10.15.2
$ rvm install 2.3.8
Search...
3
Solved
As Ruby 2.3 introduces the Safe navigation operator(&.), a.k.a lonely operator, the behavior on nil object seems odd.
nil.nil? # => true
nil&.nil? # => nil
Is that designed to beha...
Advisory asked 4/1, 2016 at 0:15
1
Solved
Could someone explain to me why in ruby console (version 2.3.4)
trying to print hashes
these work:
puts({a: 'a', b: 'b'})
puts(a: 'a', b: 'b')
puts a: 'a', b: 'b'
puts [a: 'a', b: 'b'] <<<...
Oldwife asked 10/5, 2018 at 19:7
7
Solved
After upgrading to OSX Sierra I am having an issue with random segmentation faults. It most commonly occurs when running rails test and I believe it is due to the sqlite3_adapter.
My present work ...
Gusti asked 2/10, 2016 at 0:15
1
Solved
I have Ruby 2.3.0p0 installed via rbenv, on OS X 10.11.4. Within an IRB session, history works fine. However, I cannot access IRB history across sessions.
I tried my system Ruby, 2.0.0p648, and hi...
3
Solved
I have a Hash with timestamp as keys.
hash = {
"2016-05-31T22:30:58+02:00" => {
"path" => "/",
"method" => "GET"
},
"2016-05-31T22:31:23+02:00" => {
"path" => "/tour",
"metho...
Enenstein asked 31/5, 2016 at 20:47
1
For example:
nil[1] #=> NoMethodError
nil[1]=1 #=> nil
It's not just syntax, as it happens with variables too:
a = nil
a[1] #=> NoMethodError
a[1]=1 #=> nil
Oddly:
nil.method(:[]...
1
Solved
I am building a greenfield Rails application on top of Ruby 2.3, and I would like all Rails commands (e.g. rails s, rails c) and all Ruby commands (e.g. rake do:something) to use the new immutable-...
Broyles asked 23/1, 2016 at 2:4
5
Solved
Within a method at runtime, is there a way to know if that method has been called via super in a subclass? E.g.
module SuperDetector
def via_super?
# what goes here?
end
end
class Foo
include...
Townswoman asked 12/1, 2016 at 6:23
2
The answers to every question I can find (Q1, Q2) regarding Ruby's new safe navigation operator (&.) wrongly declare that obj&.foo is equivalent to obj && obj.foo.
It's easy to dem...
Showboat asked 4/1, 2016 at 23:59
2
Solved
When a file has the pragma:
# frozen_string_literal: true
all strings written as literals in that file are frozen by default. When I want my strings to be immutable overall, and hence am using t...
1
© 2022 - 2024 — McMap. All rights reserved.