Permalink
Browse files

+ rails 3 specific changes.

  • Loading branch information...
1 parent 79f3c58 commit 9cd31f2ce7abd93f049c632adec1f48b768f077d @floere committed Jul 21, 2010
View
2 gem/lib/rails3/lib/view_models/view.rb
@@ -5,7 +5,7 @@ class View < ActionView::Base
# Shut up, opinionated funkers.
#
- alias singleton_class metaclass unless instance_methods.include?('singleton_class')
+ alias singleton_class metaclass unless instance_methods.include?(:singleton_class) || instance_methods.include?('singleton_class')
# Include the helpers from the view model.
#
View
39 rails235/config/routes.rb
@@ -1,48 +1,11 @@
ActionController::Routing::Routes.draw do |map|
- # The priority is based upon order of creation: first created -> highest priority.
map.resource :view_models do |vm|
vm.resource :book
end
- # Sample of regular route:
- # map.connect 'products/:id', :controller => 'catalog', :action => 'view'
- # Keep in mind you can assign values other than :controller and :action
-
- # Sample of named route:
- # map.purchase 'products/:id/purchase', :controller => 'catalog', :action => 'purchase'
- # This route can be invoked with purchase_url(:id => product.id)
-
- # Sample resource route (maps HTTP verbs to controller actions automatically):
- # map.resources :products
-
- # Sample resource route with options:
- # map.resources :products, :member => { :short => :get, :toggle => :post }, :collection => { :sold => :get }
-
- # Sample resource route with sub-resources:
- # map.resources :products, :has_many => [ :comments, :sales ], :has_one => :seller
-
- # Sample resource route with more complex sub-resources
- # map.resources :products do |products|
- # products.resources :comments
- # products.resources :sales, :collection => { :recent => :get }
- # end
-
- # Sample resource route within a namespace:
- # map.namespace :admin do |admin|
- # # Directs /admin/products/* to Admin::ProductsController (app/controllers/admin/products_controller.rb)
- # admin.resources :products
- # end
-
- # You can have the root of your site routed with map.root -- just remember to delete public/index.html.
- # map.root :controller => "welcome"
-
- # See how all your routes lay out with "rake routes"
-
- # Install the default routes as the lowest priority.
- # Note: These default routes make all actions in every controller accessible via GET requests. You should
- # consider removing or commenting them out if you're using named routes and resources.
map.connect ':controller/:action'
map.connect ':controller/:action/:id'
map.connect ':controller/:action/:id.:format'
+
end
View
4 rails300/Gemfile
@@ -1,2 +1,4 @@
+source :gemcutter
+
gem 'rails', '3.0.0.beta4'
-# gem 'view_models', '>=2.0.0'
+gem 'haml'
View
2 rails300/app/controllers/examples_controller.rb
@@ -1,5 +1,7 @@
class ExamplesController < ApplicationController
+ layout nil
+
def index
@items = Items.all
end
View
4 rails300/app/views/examples/index.haml
@@ -1,9 +1,9 @@
-%h1 Rails 2 Test Page
+%h1 Rails 3 Test Page
%p (for visual approval ;) Actual tests are in the gem)
%h2 The model
- model = Book.new 'This is my <script> Name', 100
-= "> A book with name '#{h(model.name)}' and # of pages #{model.pages}"
+= "> A book with name '#{model.name}' and # of pages #{model.pages}"
%h2 view_model_for
- view_model = view_model_for model
View
18 rails300/config/application.rb
@@ -1,6 +1,9 @@
require File.expand_path('../boot', __FILE__)
-require 'rails/all'
+require "action_controller/railtie"
+require "action_mailer/railtie"
+require "active_resource/railtie"
+require "rails/test_unit/railtie"
# If you have a Gemfile, require the gems listed there, including any gems
# you've limited to :test, :development, or :production.
@@ -13,8 +16,9 @@ class Application < Rails::Application
# -- all .rb files in that directory are automatically loaded.
# Add additional load paths for your own custom dirs
- # config.load_paths += %W( #{config.root}/extras )
-
+ view_models_load_path = File.join config.root, 'app', 'view_models'
+ config.load_paths << view_models_load_path
+
# Only load the plugins named here, in the order given (default is alphabetical).
# :all can be used as a placeholder for all plugins not explicitly named
# config.plugins = [ :exception_notification, :ssl_requirement, :all ]
@@ -31,11 +35,9 @@ class Application < Rails::Application
# config.i18n.default_locale = :de
# Configure generators values. Many other options are available, be sure to check the documentation.
- # config.generators do |g|
- # g.orm :active_record
- # g.template_engine :erb
- # g.test_framework :test_unit, :fixture => true
- # end
+ config.generators do |g|
+
+ end
# Configure the default encoding used in templates for Ruby 1.9.
config.encoding = "utf-8"
View
44 rails300/config/database.yml
@@ -1,22 +1,22 @@
-# # SQLite version 3.x
-# # gem install sqlite3-ruby (not necessary on OS X Leopard)
-# development:
-# adapter: sqlite3
-# database: db/development.sqlite3
-# pool: 5
-# timeout: 5000
-#
-# # Warning: The database defined as "test" will be erased and
-# # re-generated from your development database when you run "rake".
-# # Do not set this db to the same as development or production.
-# test:
-# adapter: sqlite3
-# database: db/test.sqlite3
-# pool: 5
-# timeout: 5000
-#
-# production:
-# adapter: sqlite3
-# database: db/production.sqlite3
-# pool: 5
-# timeout: 5000
+# SQLite version 3.x
+# gem install sqlite3-ruby (not necessary on OS X Leopard)
+development:
+ adapter: sqlite3
+ database: db/development.sqlite3
+ pool: 5
+ timeout: 5000
+
+# Warning: The database defined as "test" will be erased and
+# re-generated from your development database when you run "rake".
+# Do not set this db to the same as development or production.
+test:
+ adapter: sqlite3
+ database: db/test.sqlite3
+ pool: 5
+ timeout: 5000
+
+production:
+ adapter: sqlite3
+ database: db/production.sqlite3
+ pool: 5
+ timeout: 5000
View
65 rails300/config/routes.rb
@@ -1,58 +1,11 @@
Rails300::Application.routes.draw do |map|
- # The priority is based upon order of creation:
- # first created -> highest priority.
-
- # Sample of regular route:
- # match 'products/:id' => 'catalog#view'
- # Keep in mind you can assign values other than :controller and :action
-
- # Sample of named route:
- # match 'products/:id/purchase' => 'catalog#purchase', :as => :purchase
- # This route can be invoked with purchase_url(:id => product.id)
-
- # Sample resource route (maps HTTP verbs to controller actions automatically):
- # resources :products
-
- # Sample resource route with options:
- # resources :products do
- # member do
- # get :short
- # post :toggle
- # end
- #
- # collection do
- # get :sold
- # end
- # end
-
- # Sample resource route with sub-resources:
- # resources :products do
- # resources :comments, :sales
- # resource :seller
- # end
-
- # Sample resource route with more complex sub-resources
- # resources :products do
- # resources :comments
- # resources :sales do
- # get :recent, :on => :collection
- # end
- # end
-
- # Sample resource route within a namespace:
- # namespace :admin do
- # # Directs /admin/products/* to Admin::ProductsController
- # # (app/controllers/admin/products_controller.rb)
- # resources :products
- # end
-
- # You can have the root of your site routed with "root"
- # just remember to delete public/index.html.
- # root :to => "welcome#index"
-
- # See how all your routes lay out with "rake routes"
-
- # This is a legacy wild controller route that's not recommended for RESTful applications.
- # Note: This route will make all actions in every controller accessible via GET requests.
- # match ':controller(/:action(/:id(.:format)))'
+
+ map.resource :view_models do |vm|
+ vm.resource :book
+ end
+
+ map.connect ':controller/:action'
+ map.connect ':controller/:action/:id'
+ map.connect ':controller/:action/:id.:format'
+
end

0 comments on commit 9cd31f2

Please sign in to comment.