Skip to content

Commit

Permalink
+ rails 3 specific changes.
Browse files Browse the repository at this point in the history
  • Loading branch information
floere committed Jul 21, 2010
1 parent 79f3c58 commit 9cd31f2
Show file tree
Hide file tree
Showing 8 changed files with 50 additions and 128 deletions.
2 changes: 1 addition & 1 deletion gem/lib/rails3/lib/view_models/view.rb
Expand Up @@ -5,7 +5,7 @@ class View < ActionView::Base


# Shut up, opinionated funkers. # 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. # Include the helpers from the view model.
# #
Expand Down
39 changes: 1 addition & 38 deletions rails235/config/routes.rb
@@ -1,48 +1,11 @@
ActionController::Routing::Routes.draw do |map| ActionController::Routing::Routes.draw do |map|
# The priority is based upon order of creation: first created -> highest priority.


map.resource :view_models do |vm| map.resource :view_models do |vm|
vm.resource :book vm.resource :book
end 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'
map.connect ':controller/:action/:id' map.connect ':controller/:action/:id'
map.connect ':controller/:action/:id.:format' map.connect ':controller/:action/:id.:format'

end end
4 changes: 3 additions & 1 deletion rails300/Gemfile
@@ -1,2 +1,4 @@
source :gemcutter

gem 'rails', '3.0.0.beta4' gem 'rails', '3.0.0.beta4'
# gem 'view_models', '>=2.0.0' gem 'haml'
2 changes: 2 additions & 0 deletions rails300/app/controllers/examples_controller.rb
@@ -1,5 +1,7 @@
class ExamplesController < ApplicationController class ExamplesController < ApplicationController


layout nil

def index def index
@items = Items.all @items = Items.all
end end
Expand Down
4 changes: 2 additions & 2 deletions 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) %p (for visual approval ;) Actual tests are in the gem)


%h2 The model %h2 The model
- model = Book.new 'This is my <script> Name', 100 - 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 %h2 view_model_for
- view_model = view_model_for model - view_model = view_model_for model
Expand Down
18 changes: 10 additions & 8 deletions rails300/config/application.rb
@@ -1,6 +1,9 @@
require File.expand_path('../boot', __FILE__) 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 # If you have a Gemfile, require the gems listed there, including any gems
# you've limited to :test, :development, or :production. # you've limited to :test, :development, or :production.
Expand All @@ -13,8 +16,9 @@ class Application < Rails::Application
# -- all .rb files in that directory are automatically loaded. # -- all .rb files in that directory are automatically loaded.


# Add additional load paths for your own custom dirs # 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). # 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 # :all can be used as a placeholder for all plugins not explicitly named
# config.plugins = [ :exception_notification, :ssl_requirement, :all ] # config.plugins = [ :exception_notification, :ssl_requirement, :all ]
Expand All @@ -31,11 +35,9 @@ class Application < Rails::Application
# config.i18n.default_locale = :de # config.i18n.default_locale = :de


# Configure generators values. Many other options are available, be sure to check the documentation. # Configure generators values. Many other options are available, be sure to check the documentation.
# config.generators do |g| config.generators do |g|
# g.orm :active_record
# g.template_engine :erb end
# g.test_framework :test_unit, :fixture => true
# end


# Configure the default encoding used in templates for Ruby 1.9. # Configure the default encoding used in templates for Ruby 1.9.
config.encoding = "utf-8" config.encoding = "utf-8"
Expand Down
44 changes: 22 additions & 22 deletions rails300/config/database.yml
@@ -1,22 +1,22 @@
# # SQLite version 3.x # SQLite version 3.x
# # gem install sqlite3-ruby (not necessary on OS X Leopard) # gem install sqlite3-ruby (not necessary on OS X Leopard)
# development: development:
# adapter: sqlite3 adapter: sqlite3
# database: db/development.sqlite3 database: db/development.sqlite3
# pool: 5 pool: 5
# timeout: 5000 timeout: 5000
#
# # Warning: The database defined as "test" will be erased and # Warning: The database defined as "test" will be erased and
# # re-generated from your development database when you run "rake". # re-generated from your development database when you run "rake".
# # Do not set this db to the same as development or production. # Do not set this db to the same as development or production.
# test: test:
# adapter: sqlite3 adapter: sqlite3
# database: db/test.sqlite3 database: db/test.sqlite3
# pool: 5 pool: 5
# timeout: 5000 timeout: 5000
#
# production: production:
# adapter: sqlite3 adapter: sqlite3
# database: db/production.sqlite3 database: db/production.sqlite3
# pool: 5 pool: 5
# timeout: 5000 timeout: 5000
65 changes: 9 additions & 56 deletions rails300/config/routes.rb
@@ -1,58 +1,11 @@
Rails300::Application.routes.draw do |map| Rails300::Application.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
# Sample of regular route: end
# match 'products/:id' => 'catalog#view'
# Keep in mind you can assign values other than :controller and :action map.connect ':controller/:action'

map.connect ':controller/:action/:id'
# Sample of named route: map.connect ':controller/:action/:id.:format'
# 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)))'
end end

0 comments on commit 9cd31f2

Please sign in to comment.