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
pdf.bounding_box [100, 600], :width => 200 do | |
pdf.text "The rain in spain falls mainly on the plains " * 5 | |
pdf.stroke do | |
pdf.line pdf.bounds.top_left, pdf.bounds.top_right | |
pdf.line pdf.bounds.bottom_left, pdf.bounds.bottom_right | |
end | |
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
pdf.text "Hello World!" |
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
text "Hello World!" |
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
article = Article.new.save(false) # would be ideal, but `article' equals true here | |
article = Article.new | |
article.save(false) # => true | |
comment = article.comments.build | |
comment.save(false) # => true | |
# ...use these records here... |
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
article = Article.new { |a| a.save(false) } | |
comment = article.comments.build { |c| c.save(false) } |
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
article = insert! Article | |
comment = insert! Comment, :article => article | |
# ...use these records here... |
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
# This is an augmented version of the original `insert!'. In addition to the | |
# original functionality, it allows for specifying: | |
# | |
# - :trigger_validation: whether to trigger validation after the record has | |
# been instantiated. Default: false. | |
# | |
# - :inhibit_callbacks: whether to inhibit callbacks supposed to be triggered | |
# after validation. Default: true. | |
# | |
# Also, now, any attribute can be assigned, regardless of their being declared |
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
# Portable monkey patch for reloading constants before hitting metal | |
# applications. More details in the introduction article at: | |
# | |
# http://roman.flucti.com/reloading-rails-metal-applications | |
# | |
Rails::Rack::Metal.class_eval do | |
# Prevent Metal from further require'ing source files, in order to let | |
# AS::Dependencies handle constants. | |
class << self |
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
# Minimalistic Mininova TV show browser with live search, written in Shoes. | |
# | |
# To run it, drop `minishoes.rb' onto `Shoes.app'. You should see something like | |
# the screen capture at: | |
# http://img4.imageshack.us/img4/106/minishows.png | |
# | |
require 'pathname' | |
require 'hpricot' | |
require 'open-uri' |
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
def on_time_value | |
attendances.inject(0) do |sum, attendance| | |
sum + (attendance.late? ? 0 : 5) | |
end | |
end |