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 MyController < Application | |
cache :show, :index | |
after nil, :only => :create do | |
eager_cache :show{ |c| c.params[:id] => @article.id} | |
eager_cache :index | |
end | |
def index |
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
# My spec ... | |
it "should not put the value of the last <option> attributes in to the attributes of the select tag" do | |
content = select(:collection => %w(one two three), :selected => 'three') | |
content.should_not match_tag(:select, :value => "three", :selected => "selected") | |
end | |
def options(col, text_meth, value_meth, attrs, sel, b) | |
opt_attrs = attrs.dup | |
options = [b] + col.map do |item| | |
value = item.send(value_meth) |
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 MerbPrivilege::Roles < MerbPrivilege::Application | |
def index | |
@roles = Role.all | |
@role ||= Role.new | |
render | |
end | |
def create | |
@role = Role.new(:id => nil, :description => params[:role][:description]) |
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
Merb.logger.info("Compiling routes...") | |
Merb::Router.prepare do | |
# Administration | |
match('/admin').to(:namespace => "admin") do | |
resources :locations | |
resources :users | |
resources :links | |
match("/offer").to(:controller => "offer") do | |
match(:method => "get").to(:action => "show").name(:offer) | |
match("/edit", :method => "get").to(:action => "edit").name(:edit_offer) |
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
Merb.logger.info("Compiling routes...") | |
Merb::Router.prepare do | |
# Administration | |
match('/admin').to(:namespace => "admin") do | |
resources :locations | |
resources :users | |
resources :links | |
match("/offer").to(:controller => "offer") do | |
match(:method => "get").to(:action => "show").name(:offer) | |
match("/edit", :method => "get").to(:action => "edit").name(:edit_offer) |
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
Throw your "static" views in app/views/static... and it just works, page cached and all. |
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 ChangeTaxRate < ActiveRecord::Migration | |
def self.up | |
execute "ALTER TABLE `tax_rates` CHANGE `rate` `rate` DECIMAL( 8, 6 ) NULL DEFAULT '0.0000'" | |
end | |
def self.down | |
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
namespace :api do | |
match("/:version", :version => /\d\.\d/) do | |
match("").to(:controller => "main").name(:api) | |
resources :users | |
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
Merb::Router.prepare do | |
# RESTful routes | |
# resources :posts | |
identify Post => :permalink do | |
resources :posts | |
match("/").to(:controller => "posts") | |
end | |
end | |
OlderNewer