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.impressions.create | |
article.impressions.create(:created_at => "2000-01-01") | |
article.impressions.create(:created_at => "2000-01-01") | |
article.impressions.create(:created_at => "2000-01-02") | |
impressions = article.impressions.select("count(*) as count, DATE_FORMAT(created_at,'%Y-%m-%d') as created_day").group("created_day") | |
impressions.each do |impression| | |
p "#{impression.created_day}: #{impression.count}" | |
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
# Rails 3.2.6 | |
# my_engine/app/models/user.rb | |
# Define class in engine | |
class User < ActiveRecord::Base | |
#methods here | |
end | |
# my_rails_app/app/models/user.rb |
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 "acts_as_charlie_sheen" | |
require "rails" | |
module ActsAsCharlieSheen | |
class Railtie < Rails::Railtie | |
initializer 'acts_as_charlie_sheen.ar_extensions' do |app| | |
ActiveRecord::Base.extend ActsAsCharlieSheen::Base | |
end | |
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
module ActsAsCharlieSheen | |
module Base | |
def acts_as_charlie_sheen | |
include InstanceMethods | |
end | |
module InstanceMethods | |
def sheenify! | |
["WINNING!", | |
"TIGER BLOOD!", |
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
<p id="notice"><%= notice %></p> | |
<h1><%[email protected]! %></h1> | |
<%= link_to 'Edit', edit_person_path(@person) %> | | |
<%= link_to 'Back', people_path %> |
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 Person < ActiveRecord::Base | |
acts_as_charlie_sheen | |
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
gem 'acts_as_charlie_sheen', :git => 'git://github.com/your_username/acts_as_charlie_sheen.git' |
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 'acts_as_charlie_sheen/base' | |
require 'acts_as_charlie_sheen/railtie' |
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
Jeweler::Tasks.new do |gem| | |
gem.name = "acts_as_charlie_sheen" | |
gem.homepage = "http://github.com/johnmcaliley/acts_as_charlie_sheen" | |
gem.license = "MIT" | |
gem.summary = %Q{Make your classes act like Charlie Sheen} | |
gem.description = %Q{Adds functionality to classes to make them act like Charlie Sheen. WINNING!} | |
gem.email = "[email protected]" | |
gem.authors = ["John McAliley"] | |
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
Jeweler::Tasks.new do |gem| | |
# gem is a Gem::Specification... see http://docs.rubygems.org/read/chapter/20 for more options | |
gem.name = "acts_as_charlie_sheen" | |
gem.homepage = "http://github.com/johnmcaliley/acts_as_charlie_sheen" | |
gem.license = "MIT" | |
gem.summary = %Q{Make your classes act like Charlie Sheen} | |
gem.description = %Q{Adds functionality to classes to make them act like Charlie Sheen. WINNING!} | |
gem.email = "[email protected]" | |
gem.authors = ["John McAliley"] | |
end |
NewerOlder