This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
nil.nil? | |
=> true | |
false.nil? | |
=> false | |
1.nil? | |
=> false | |
0.nil? |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#one way | |
Model.all.map(&:field_name) | |
#second way | |
@bars = Bar.all(:select => bar.id) | |
@bars = @bars.map{|bar| bar.id} | |
#third way use pluck | |
Model.all.pluck(:field_name) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#events is a model with key as one of the columns | |
Hash[events.map { |u| [u.key, u] }] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
puts "Title \t ID \t Preferred" | |
client.discovered_apis.each do |gapi| | |
puts "#{gapi.title} \t #{gapi.id} \t #{gapi.preferred}" | |
end |