![](data:image/jpeg;base64,/9j/4AAQSkZJRgABAQAAAQABAAD/2wBDAAgGBgcGBQgHBwcJCQgKDBQNDAsLDBkSEw8UHRofHh0aHBwgJC4nICIsIxwcKDcpLDAxNDQ0Hyc5PTgyPC4zNDL/2wBDAQkJCQwLDBgNDRgyIRwhMjIyMjIyMjIyMjIyMjIyMjIyMjIyMjIyMjIyMjIyMjIyMjIyMjIyMjIyMjIyMjIyMjL/wgARCAMABAADASIAAhEBAxEB/8QAGwAAAwEBAQEBAAAAAAAAAAAAAQIDAAQFBgf/xAAYAQEBAQEBAAAAAAAAAAAAAAAAAQIDBP/aAAwDAQACEAMQAAABVdTxSL9UWYbsReY7pONfQjXIelLecdPSnnt1NJw7pioWrJBbxtVetq4SnSc49KNefufN9W52k6DzmOjQY6TzGOk8+joPOS2lktomWwnh8i210sVaBlsYEsYNFm52LaOKvzst9Jsy2ibroPM9tWg8USQstpyXrRBmU0wmVV1WVBpkVacTybKtFQllBNasYYvoEsefHRucL07nx0bnx0Hl1dB5cXHNq6jyZOo8uOpIAuvOp1bk1dY5QnUOUV09Hm9S+zJpcM10jJQKFYKtUVdRAwXnkco0EZQjCspxgVMrLWVhaNsFlMMQYLq8mO0FlMHHBJMA4gzFVV9SBis84ELZTg0YgmOKpQFp8NnJSkt7OU61cypmTEqarzKx0CNc5OUyLNjqyZXtjK6zMxbasZ0KTl0TSD0FkQ+uVzaEz62ecCkkGbExUVNaLU1qlLtg7Y2wQI6UuGo5cmI1Dq5epfTlSHCVyhHCgITWuUwwwGKlGZDDAEAIAMocuohRTDAYhoDYmctliTCk6McQ7GCcQMGUg422FxyqxwubADKo2Jqzu1zutLtSumRdaXpA1naDaayZ5QS+rSsyTfnqmfFZpVSbVMcaWTWUD4g1AQoyovPdXOT5kQs0IKEjq6p5sKKYkKiopdLOdbJohwrAg
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
# elixir provides a way to fetch from and update nested maps | |
# lets say you have a map: | |
greetings = %{morning: %{friend: "sup", coworker: "hey"}, afternoon: %{friend: "sup", coworker: "good afternoon"}} | |
# there is a built in (erlang) Kernel function `get_in` | |
get_in(greetings, [:morning, :coworker]) #=> "hey" | |
# to updated a nested map use `put_in` | |
new_greetings = put_in(greetings, [:afternoon, :friend], "yo there") # => %{afternoon: %{coworker: "good afternoon", friend: "yo there"}, morning: %{coworker: "hey", friend: "sup"}} |
Intro
JETHRO: Hello, my name is Jethro Wilkins and you're on pimp my site.
JETHRO: Craig came in today looking for some help with his blog. Craig loves his cat but his blog could really use some help. It looks dull, uninteresting and boring to look at. Looks like something his grandma would blog about. So he came in here looking for some help.
CRAIG: Everyone says they like the pictures of my cat, but they can't stand be on the site for more than 2 minutes. I don't know, maybe it's the gray background or something...but bottom line is I need these guys to really help me out.
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
module RelevantTag | |
extend ActiveSupport::Concern | |
included do | |
has_many :taggings, as: :taggable | |
has_many :tags, through: :taggings | |
class_attribute :tag_limit | |
end |
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
git checkout <branch_name> -- <space-separated paths> |
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
# Change field_with_errors to just add 'error' class to label and element | |
# instead of wrapping input and label in a div tag | |
# label blocks do not proc for errors in rails 3.2 | |
ActionView::Base.field_error_proc = Proc.new do |tag, full_html| | |
if tag =~ /<(input|label|textarea|select)/ | |
field = Nokogiri::HTML::DocumentFragment.parse(tag) | |
field.children.add_class 'error' | |
field.to_s.html_safe | |
else | |
tag |