Just a couple notes for quick referencing in the future in case I forget.
- Use %Q to add double quotes around a string for cleaner looking strings that require double quotes.
puts %Q|{"message":"Malformed url #{image[:uri]}", "_id": "#{@test["_id"]}", "field_name": "#{image[:description]}"}|
A pretty good read up can be found here
- When including a class, the main class gets access to all the included class's methods. The included class also gets access to the main class's instance variables.
class First
include Second
def initialize
@monkey = "wont do"
end
end
class Second
def what_about_the_monkey
puts @monkey #prints out "wont do"
end
end
-
In Ruby, valid JSON requires double quotes unlike Javascript where the preferred way is with single quotes.
-
In Ruby, the & does way too much. Good read found here