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 File.join( File.dirname(__FILE__), '../..', "spec_helper" ) | |
module Templating | |
def template(opts) | |
template = { | |
:name => "Default Template", | |
:file_name => "default", | |
:type => "view", | |
:format => "html", | |
:language => "haml" |
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
different prefix: "/" and "." | |
/usr/lib/ruby/1.8/pathname.rb:709:in `relative_path_from' | |
/usr/lib/ruby/gems/1.8/gems/merb-core-0.9.8/lib/merb-core/dispatch/default_exception/default_exception.rb:24:in `frame_details' | |
/usr/lib/ruby/gems/1.8/gems/merb-core-0.9.8/lib/merb-core/dispatch/default_exception/views/index.html.erb:69:in `__usr__lib__ruby__gems__1_8__gems__merb__core__0_9_8__lib__merb__core__dispatch__default__exception__views__index_html_erb' | |
/usr/lib/ruby/1.8/pathname.rb:709:in `each_with_index' | |
/usr/lib/ruby/gems/1.8/gems/merb-core-0.9.8/lib/merb-core/dispatch/default_exception/views/index.html.erb:68:in `each' | |
/usr/lib/ruby/gems/1.8/gems/merb-core-0.9.8/lib/merb-core/dispatch/default_exception/views/index.html.erb:68:in `each_with_index' | |
/usr/lib/ruby/gems/1.8/gems/merb-core-0.9.8/lib/merb-core/dispatch/default_exception/views/index.html.erb:68:in `__usr__lib__ruby__gems__1_8__gems__merb__core__0_9_8__lib__merb__core__dispatch__default__exception__views__index_html_erb' | |
/usr/lib/ruby/1.8/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
NameError: wrong constant name MelonTest::Jam | |
from /opt/local/lib/ruby/gems/1.8/gems/dm-core-0.9.6/lib/dm-core/associations/many_to_many.rb:60:in `const_defined?' | |
from /opt/local/lib/ruby/gems/1.8/gems/dm-core-0.9.6/lib/dm-core/associations/many_to_many.rb:60:in `setup' | |
from /opt/local/lib/ruby/gems/1.8/gems/dm-core-0.9.6/lib/dm-core/associations.rb:122:in `has' | |
from ./assoc_test.rb:8 | |
from /opt/local/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:27:in `gem_original_require' | |
from /opt/local/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:27:in `require' | |
from (irb):2 | |
from :0 |
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
# This allows users to publish the path to the public pages | |
Merb::Router.extensions do | |
def gluttonberg_pages(prefix = nil) | |
path = prefix ? "/#{prefix}/:path" : "/:path" | |
match(path, :path => /\S+/). | |
to(:controller => "gluttonberg/content/public", :action => "show"). | |
name(:gluttonberg_public_page) | |
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
class SalesTotals | |
include DataMapper::Resource | |
include DataMapper::Caching | |
property :id, Serial | |
property :sales, Integer | |
property :items, Integer | |
property :value, Money | |
property :start_at, Time | |
property :end_at, Time |
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
# Called like: | |
@page = Page.first_with_localization(:path =>"about_us", :dialect_id => 2, :locale_id => 1) | |
def self.first_with_localization(options) | |
if options[:path] == "" or options[:path].nil? | |
options.delete(:path) | |
page = Page.first(:home => true) | |
raise DataMapper::ObjectNotFoundError unless page | |
localization = page.localizations.first(options) | |
raise DataMapper::ObjectNotFoundError unless localization |
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
The idea is to be able to examine a path inside a #defer_to block and | |
optionally rewrite parts of the request — path, subdomain etc. After the | |
rewrite, the request will go through the router again, where any matching | |
routes will then pick it up. |
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
$KCODE = 'UTF8' | |
require 'dm-core' | |
dependency "merb-assets" | |
use_orm :datamapper | |
use_test :rspec | |
use_template_engine :haml | |
Merb::Config.use do |c| |
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
* Raise a 404 if the dialect, locale, localization or page is missing | |
* Check the modes correctly — including falling back to a default | |
* Account for requests to the root | |
* Move a bunch of this logic out into it's own module | |
* Investigate a way to find the localization without repeated finds | |
* Finesse the path rewriting a LOT more, since this won't work properly | |
* Consider having forcing public controllers to be namespaced to prevent collisions with the page slugs | |
* Remember to note that this call has to go at the bottom of the router, or shit will blow up |
OlderNewer