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 DataMapperInitializer | |
def self.registered(app) | |
app.configure :production do | |
DataMapper.setup(:default, 'your_db_here') | |
end | |
app.configure :development do | |
DataMapper.setup(:default, 'your_db_dev_here') | |
end | |
app.configure :test do | |
DataMapper.setup(:default,'your_db_test_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
project :test => :shoulda, :orm => :activerecord, :dev => true | |
generate :model, "post title:string body:text" | |
generate :controller, "posts get:index get:new post:new" | |
generate :migration, "AddEmailToUser email:string" | |
generate :fake, "foo bar" | |
require_dependencies 'nokogiri' | |
inject_into_file "app/models/post.rb","#Hello", :after => "end\n" |
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
project :test => :shoulda, :renderer => :haml, :stylesheet => :sass, :script => :jquery, :orm => :activerecord | |
#default routes | |
APP_INIT = <<-APP | |
get "/" do | |
"Hello World!" | |
end | |
get :about, :map => '/about_us' do | |
render :haml, "%p This is a sample blog created to demonstrate the power of Padrino!" |
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
CODERAY = <<-CODERAY | |
require 'rack/coderay' | |
app.use Rack::Coderay, | |
"//pre[@lang]", | |
:line_numbers => :table | |
CODERAY | |
require_dependencies 'coderay', 'rack-coderay' | |
initializer :coderay,CODERAY | |
get 'http://coderay.rubychan.de/stylesheets/coderay.css', 'public/stylesheets/coderay.css' |
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
vendor_path = File.dirname(__FILE__) + '/vendor' | |
# Padrino | |
%w(core gen helpers mailer admin).each do |gem| | |
padrino_lib = vendor_path + '/padrino-framework' | |
gem 'padrino-' + gem, :path => "#{padrino_lib}/padrino-" + gem | |
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
Admin.controllers :accounts do | |
get :index do | |
@accounts = Account.all | |
render 'accounts/index' | |
end | |
get :new do | |
@account = Account.new | |
render 'accounts/new' |
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
# /Library/Ruby/Gems/1.8/gems/activesupport-2.3.5/lib/active_support/dependencies.rb in const_missing | |
# | |
98. parent.send :const_missing, const_name | |
99. end | |
100. rescue NameError => e | |
101. # Make sure that the name we are missing is the one that caused the error | |
102. parent_qualified_name = Dependencies.qualified_name_for parent, const_name | |
103. raise unless e.missing_name? parent_qualified_name | |
104. qualified_name = Dependencies.qualified_name_for self, const_name |
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
# /Library/Ruby/Gems/1.8/gems/activesupport-2.3.5/lib/active_support/dependencies.rb in load_missing_constant | |
# | |
436. begin | |
437. return parent.const_missing(const_name) | |
438. rescue NameError => e | |
439. raise unless e.missing_name? qualified_name_for(parent, const_name) | |
440. raise name_error | |
441. end | |
442. else |
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
get :new do | |
you went to "/new" | |
end | |
get :new, :with => :id do | |
"you went to /new/123" | |
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 Photo | |
include Mongoid::Document | |
include Mongoid::Timestamps # adds created_at and updated_at fields | |
# fields | |
field :caption, :type => String | |
field :tags, :type => Array, :default => [] | |
before_save :make_tags | |
OlderNewer