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
require 'md5' | |
module CommentsHelper | |
def gravatar_url_for(email = null, size = 80) | |
hash = MD5::md5(email.downcase) | |
image_src = "http://www.gravatar.com/avatar/#{hash}?s=#{size}" | |
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
<%= image_tag(gravatar_url_for(comment.email)) %> |
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
map.connect 'archives/:year/:month', | |
:controller => 'posts', | |
:action => 'find_by_date', | |
:year => /\d{4}/, | |
:month => /(jan|feb|mar|apr|may|jun|jul|aug|sep|oct|nov|dec)/ |
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 find_by_date | |
@posts = Post.find(:all, | |
:conditions => ["monthname(created_at) = ? AND year(created_at) = ?", | |
params[:month], params[:year]]) | |
render :action => "index" | |
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
def to_param | |
"#{id}-#{title.gsub(/[^a-z0-9]+/i, '-')}" | |
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
class Report | |
def create_report | |
# Left blank, sub-classes will implement this | |
end | |
end | |
class XmlReport < Report | |
def create_report | |
puts "I am an Xml Report" | |
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
class ReportGenerator | |
def print_report(report_type) | |
report_type.create_report | |
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
rep_gen = ReportGenerator.new | |
my_reports = [XmlReport.new, TextReport.new, HtmlReport.new, PdfReport.new] | |
my_reports.each do |report| | |
rep_gen.print_report(report) | |
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
user = User.find(1) | |
user_orders = user.orders |
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
<div class="span-6"></div> |
OlderNewer