This file contains hidden or 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 hidden or 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 hidden or 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><%=@person.sheenify! %></h1> | |
| <%= link_to 'Edit', edit_person_path(@person) %> | | |
| <%= link_to 'Back', people_path %> |
This file contains hidden or 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 hidden or 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 hidden or 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 hidden or 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 |
OlderNewer