Skip to content

Instantly share code, notes, and snippets.

<% # app/views/stores/show.html.erb %>
<% cache ["v3", @store] do%>
<h1>Store: <%= @store.name %></h1>
<%= render @store.employees %>
<% end %>
<% # app/views/employees/_employee.html.erb %>
<% cache ["v3", employee] do %>
<div class='employee'>
<!-- app/views/stores/show.html.erb -->
<% cache ["v3", @store] do%>
<h1>Store: <%= @store.name %></h1>
<%= render @store.employees %>
<% end %>
<!-- app/views/employees/_employee.html.erb -->
<% cache ["v3", employee] do %>
<div class='employee'>
Student.where(name: "Little Johnny DropTable").first_or_create
# => <Student id: 1, first_name: 'Little Johnny DropTable', grade: 2>
Student.where(name: "Sally Sue", grade: 5).first_or_create
# => <Student id: 2, first_name: 'Sally Sue', grade: 5>
Student.find_or_create_by_name("Little Johnny DropTable")
Student.find_or_create_by_name_and_grade("Sally Sue", 5)
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.7.2/jquery.min.js"></script>
<script src="http://static.tumblr.com/fpifyru/VCxlv9xwi/writecapture.js"></script>
<script src="http://static.tumblr.com/eojssfq/QG5m6cm3z/embedgist.js"></script>
module SlimySlug
extend ActiveSupport::Concern
included do
before_save :set_slug
has_many :actions
has_many :lobbyists, through: :actions
has_many :clients, through: :actions
end
module SlimySlug
extend ActiveSupport::Concern
included do
before_save :set_slug
end
def set_slug
self.slug = self.name.downcase.gsub('.','').gsub(' ','-')
end
puts noko_obj.to_html['tbody']
#=> nil
def return_nokogiri_table_rows(noko_obj)
noko_obj.xpath('/html/body/table/tr/td/table[3]/tr[4]/td[2]/table/tr/td')
end
def return_nokogiri_table_rows(noko_obj)
noko_obj.xpath('/html/body/table/tbody/tr/td/table[3]/tbody/tr[4]/td[2]/table/tbody/tr/td')
end