diff --git a/.gitignore b/.gitignore index 0f38f930..7a9f55cb 100644 --- a/.gitignore +++ b/.gitignore @@ -1,3 +1,5 @@ +.bundle +db/*.sqlite3 log/*.log tmp/**/* .DS_Store diff --git a/Gemfile b/Gemfile new file mode 100644 index 00000000..9abb03d4 --- /dev/null +++ b/Gemfile @@ -0,0 +1,32 @@ +# Edit this Gemfile to bundle your application's dependencies. +source 'http://gemcutter.org' + +gem "rails", "3.0.0.beta" + +gem "liquid" + +# http://github.com/merbjedi/mongomapper +gem "mongo_mapper-rails3", :require => "mongo_mapper" +#gem 'grip' + +gem 'warden' +gem 'devise', "1.1.pre" + +## Bundle edge rails: +# gem "rails", :git => "git://github.com/rails/rails.git" + +# ActiveRecord requires a database adapter. By default, +# Rails has selected sqlite3. +# gem "sqlite3-ruby", :require => "sqlite3" + +## Bundle the gems you use: +# gem "bj" +# gem "hpricot", "0.6" +# gem "sqlite3-ruby", :require => "sqlite3" +# gem "aws-s3", :require => "aws/s3" + +## Bundle gems used only in certain environments: +# gem "rspec", :group => :test +# group :test do +# gem "webrat" +# end diff --git a/Rakefile b/Rakefile index 3bb0e859..9cb20464 100644 --- a/Rakefile +++ b/Rakefile @@ -1,10 +1,10 @@ # Add your own tasks in files placed in lib/tasks ending in .rake, # for example lib/tasks/capistrano.rake, and they will automatically be available to Rake. -require(File.join(File.dirname(__FILE__), 'config', 'boot')) +require File.expand_path('../config/application', __FILE__) require 'rake' require 'rake/testtask' require 'rake/rdoctask' -require 'tasks/rails' +Rails::Application.load_tasks diff --git a/app/controllers/application_controller.rb b/app/controllers/application_controller.rb index c380716f..8834b5d0 100644 --- a/app/controllers/application_controller.rb +++ b/app/controllers/application_controller.rb @@ -1,8 +1,8 @@ class ApplicationController < ActionController::Base - - helper :all protect_from_forgery - + + helper :all + before_filter :set_locale filter_parameter_logging :password @@ -42,5 +42,5 @@ class ApplicationController < ActionController::Base render :text => 'missing entry_name' if params[:entry_name].blank? return end - + end diff --git a/app/controllers/pages_controller.rb b/app/controllers/pages_controller.rb index 92644ad6..d4ad8946 100644 --- a/app/controllers/pages_controller.rb +++ b/app/controllers/pages_controller.rb @@ -10,7 +10,7 @@ class PagesController < ApplicationController end def show - @page = Page.find_by_full_name(params[:page_name].join("/")) + @page = Page.find_by_full_name(params[:page_name]) render_liquid_page end diff --git a/app/helpers/admin_helper.rb b/app/helpers/admin_helper.rb index c7d07fdf..9d85d13e 100644 --- a/app/helpers/admin_helper.rb +++ b/app/helpers/admin_helper.rb @@ -2,7 +2,7 @@ module AdminHelper def show_parent_items_link(parent_item) @parent_items = @parent_item.ancestors.map{ |i| i.name } - ( @parent_items.map{ |i| link_to(i, admin_items_path(:parent_name=>i) ) } << parent_item.name ).join("/") + ( @parent_items.map{ |i| link_to(i, admin_items_path(:parent_name=>i) ) } << parent_item.name ).join("/").html_safe end end \ No newline at end of file diff --git a/app/helpers/application_helper.rb b/app/helpers/application_helper.rb index 22a7940e..de6be794 100644 --- a/app/helpers/application_helper.rb +++ b/app/helpers/application_helper.rb @@ -1,3 +1,2 @@ -# Methods added to this helper will be available to all templates in the application. module ApplicationHelper end diff --git a/app/views/layouts/admin.html.erb b/app/views/layouts/admin.html.erb index 7f2ea76c..1dcb952c 100644 --- a/app/views/layouts/admin.html.erb +++ b/app/views/layouts/admin.html.erb @@ -39,7 +39,7 @@ <%= javascript_include_tag "jquery", "jquery-ui", - "jrails", + "rails", "easy", "application", :cache => 'all' %> <%= yield :page_specific_javascript %> diff --git a/app/views/layouts/panel.html.erb b/app/views/layouts/panel.html.erb index ff1eb0b7..af33440b 100644 --- a/app/views/layouts/panel.html.erb +++ b/app/views/layouts/panel.html.erb @@ -37,7 +37,7 @@ <%= javascript_include_tag "jquery", "jquery-ui", - "jrails", + "rails", "easy", "application", :cache => 'all' %> <%= yield :page_specific_javascript %> diff --git a/config.ru b/config.ru new file mode 100644 index 00000000..c7cc1387 --- /dev/null +++ b/config.ru @@ -0,0 +1,4 @@ +# This file is used by Rack-based servers to start the application. + +require ::File.expand_path('../config/environment', __FILE__) +run R4::Application diff --git a/config/application.rb b/config/application.rb new file mode 100644 index 00000000..740179bf --- /dev/null +++ b/config/application.rb @@ -0,0 +1,53 @@ +require File.expand_path('../boot', __FILE__) + +# Pick the frameworks you want: +# require "active_record/railtie" +require "action_controller/railtie" +require "action_mailer/railtie" +# require "active_resource/railtie" +# require "rails/test_unit/railtie" +require File.expand_path('lib/reroute_middleware') + +# Auto-require default libraries and those for the current Rails environment. +Bundler.require :default, Rails.env + +module R4 + class Application < Rails::Application + config.middleware.use RerouteMiddleware + + # Settings in config/environments/* take precedence over those specified here. + # Application configuration should go into files in config/initializers + # -- 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 ) + + # 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 ] + + # Activate observers that should always be running + # config.active_record.observers = :cacher, :garbage_collector, :forum_observer + + # Set Time.zone default to the specified zone and make Active Record auto-convert to this zone. + # Run "rake -D time" for a list of tasks for finding time zone names. Default is UTC. + config.time_zone = 'Taipei' + + # The default locale is :en and all translations from config/locales/*.rb,yml are auto loaded. + # config.i18n.load_path += Dir[Rails.root.join('my', 'locales', '*.{rb,yml}')] + config.i18n.default_locale = :zh_tw + + # 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 + + # Configure sensitive parameters which will be filtered from the log file. + config.filter_parameters << :password + + end +end + +VALID_LOCALES = ["en", "zh_tw"] diff --git a/config/boot.rb b/config/boot.rb index 0ad0f787..29c9d506 100644 --- a/config/boot.rb +++ b/config/boot.rb @@ -1,110 +1,17 @@ -# Don't change this file! -# Configure your app in config/environment.rb and config/environments/*.rb +# Use Bundler (preferred) +begin + require File.expand_path('../../.bundle/environment', __FILE__) +rescue LoadError + require 'rubygems' + require 'bundler' + Bundler.setup -RAILS_ROOT = "#{File.dirname(__FILE__)}/.." unless defined?(RAILS_ROOT) - -module Rails - class << self - def boot! - unless booted? - preinitialize - pick_boot.run - end - end - - def booted? - defined? Rails::Initializer - end - - def pick_boot - (vendor_rails? ? VendorBoot : GemBoot).new - end - - def vendor_rails? - File.exist?("#{RAILS_ROOT}/vendor/rails") - end - - def preinitialize - load(preinitializer_path) if File.exist?(preinitializer_path) - end - - def preinitializer_path - "#{RAILS_ROOT}/config/preinitializer.rb" - end - end - - class Boot - def run - load_initializer - Rails::Initializer.run(:set_load_path) - end - end - - class VendorBoot < Boot - def load_initializer - require "#{RAILS_ROOT}/vendor/rails/railties/lib/initializer" - Rails::Initializer.run(:install_gem_spec_stubs) - Rails::GemDependency.add_frozen_gem_path - end - end - - class GemBoot < Boot - def load_initializer - self.class.load_rubygems - load_rails_gem - require 'initializer' - end - - def load_rails_gem - if version = self.class.gem_version - gem 'rails', version - else - gem 'rails' - end - rescue Gem::LoadError => load_error - $stderr.puts %(Missing the Rails #{version} gem. Please `gem install -v=#{version} rails`, update your RAILS_GEM_VERSION setting in config/environment.rb for the Rails version you do have installed, or comment out RAILS_GEM_VERSION to use the latest version installed.) - exit 1 - end - - class << self - def rubygems_version - Gem::RubyGemsVersion rescue nil - end - - def gem_version - if defined? RAILS_GEM_VERSION - RAILS_GEM_VERSION - elsif ENV.include?('RAILS_GEM_VERSION') - ENV['RAILS_GEM_VERSION'] - else - parse_gem_version(read_environment_rb) - end - end - - def load_rubygems - require 'rubygems' - min_version = '1.3.1' - unless rubygems_version >= min_version - $stderr.puts %Q(Rails requires RubyGems >= #{min_version} (you have #{rubygems_version}). Please `gem update --system` and try again.) - exit 1 - end - - rescue LoadError - $stderr.puts %Q(Rails requires RubyGems >= #{min_version}. Please install RubyGems and try again: http://rubygems.rubyforge.org) - exit 1 - end - - def parse_gem_version(text) - $1 if text =~ /^[^#]*RAILS_GEM_VERSION\s*=\s*["']([!~<>=]*\s*[\d.]+)["']/ - end - - private - def read_environment_rb - File.read("#{RAILS_ROOT}/config/environment.rb") - end - end - end + # To use 2.x style vendor/rails and RubyGems + # + # vendor_rails = File.expand_path('../../vendor/rails', __FILE__) + # if File.exist?(vendor_rails) + # Dir["#{vendor_rails}/*/lib"].each { |path| $:.unshift(path) } + # end + # + # require 'rubygems' end - -# All that for this: -Rails.boot! diff --git a/config/environment.rb b/config/environment.rb index 9f228628..5cde9249 100644 --- a/config/environment.rb +++ b/config/environment.rb @@ -1,76 +1,5 @@ -# Be sure to restart your server when you modify this file - -# Specifies gem version of Rails to use when vendor/rails is not present -RAILS_GEM_VERSION = '2.3.5' unless defined? RAILS_GEM_VERSION - -# Bootstrap the Rails environment, frameworks, and default configuration -require File.join(File.dirname(__FILE__), 'boot') - -Rails::Initializer.run do |config| - # Settings in config/environments/* take precedence over those specified here. - # Application configuration should go into files in config/initializers - # -- all .rb files in that directory are automatically loaded. - - # Add additional load paths for your own custom dirs - # config.load_paths += %W( #{RAILS_ROOT}/extras ) - - # Specify gems that this application depends on and have them installed with rake gems:install - # config.gem "bj" - # config.gem "hpricot", :version => '0.6', :source => "http://code.whytheluckystiff.net" - # config.gem "sqlite3-ruby", :lib => "sqlite3" - # config.gem "aws-s3", :lib => "aws/s3" - - config.gem "liquid" - config.gem "mongo_mapper" - config.gem 'grip' - config.gem "devise", :version => '1.0.1' - - # 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 ] - - # Skip frameworks you're not going to use. To use Rails without a database, - # you must remove the Active Record framework. - config.frameworks -= [ :active_record ] - - # Activate observers that should always be running - # config.active_record.observers = :cacher, :garbage_collector, :forum_observer - - # Set Time.zone default to the specified zone and make Active Record auto-convert to this zone. - # Run "rake -D time" for a list of tasks for finding time zone names. - config.time_zone = "Taipei" - - # The default locale is :en and all translations from config/locales/*.rb,yml are auto loaded. - # config.i18n.load_path += Dir[Rails.root.join('my', 'locales', '*.{rb,yml}')] - config.i18n.default_locale = "zh_tw" - - config.middleware.use :RerouteMiddleware - -end - -#VALID_LOCALES = ["en", "zh_tw"] -VALID_LOCALES = ["en", "zh_tw"] - -MongoMapper.database = "r4-#{Rails.env}" - -module MongoMapper::Document::ClassMethods - - def key_i18n(key, *options) - VALID_LOCALES.each do |locale| - key "#{key.to_s}_#{locale}".to_sym, *options - end - - define_method(key) do - self.send("#{key.to_s}_#{I18n.locale}") - end - - define_method("#{key}=") do |value| - VALID_LOCALES.each do |locale| - self.send("#{key.to_s}_#{locale}=", value) - end - end - end - -end - +# Load the rails application +require File.expand_path('../application', __FILE__) +# Initialize the rails application +R4::Application.initialize! diff --git a/config/environments/development.rb b/config/environments/development.rb index 43762f27..2b315af1 100644 --- a/config/environments/development.rb +++ b/config/environments/development.rb @@ -1,19 +1,20 @@ -# Settings specified here will take precedence over those in config/environment.rb +R4::Application.configure do + # Settings specified here will take precedence over those in config/environment.rb -# In the development environment your application's code is reloaded on -# every request. This slows down response time but is perfect for development -# since you don't have to restart the webserver when you make code changes. -config.cache_classes = false + # In the development environment your application's code is reloaded on + # every request. This slows down response time but is perfect for development + # since you don't have to restart the webserver when you make code changes. + config.cache_classes = false -# Log error messages when you accidentally call methods on nil. -config.whiny_nils = true + # Log error messages when you accidentally call methods on nil. + config.whiny_nils = true -# Show full error reports and disable caching -config.action_controller.consider_all_requests_local = true -config.action_view.debug_rjs = true -config.action_controller.perform_caching = false + # Show full error reports and disable caching + config.consider_all_requests_local = true + config.action_view.debug_rjs = true + config.action_controller.perform_caching = false -# Don't care if the mailer can't send -config.action_mailer.raise_delivery_errors = false + # Don't care if the mailer can't send + config.action_mailer.raise_delivery_errors = false -config.action_mailer.default_url_options = { :host => 'localhost:3000' } \ No newline at end of file +end diff --git a/config/environments/production.rb b/config/environments/production.rb index 27119d2d..5078253b 100644 --- a/config/environments/production.rb +++ b/config/environments/production.rb @@ -1,28 +1,33 @@ -# Settings specified here will take precedence over those in config/environment.rb +R4::Application.configure do + # Settings specified here will take precedence over those in config/environment.rb -# The production environment is meant for finished, "live" apps. -# Code is not reloaded between requests -config.cache_classes = true + # The production environment is meant for finished, "live" apps. + # Code is not reloaded between requests + config.cache_classes = true -# Full error reports are disabled and caching is turned on -config.action_controller.consider_all_requests_local = false -config.action_controller.perform_caching = true -config.action_view.cache_template_loading = true + # Full error reports are disabled and caching is turned on + config.consider_all_requests_local = false + config.action_controller.perform_caching = true -# See everything in the log (default is :info) -# config.log_level = :debug + # See everything in the log (default is :info) + # config.log_level = :debug -# Use a different logger for distributed setups -# config.logger = SyslogLogger.new + # Use a different logger for distributed setups + # config.logger = SyslogLogger.new -# Use a different cache store in production -# config.cache_store = :mem_cache_store + # Use a different cache store in production + # config.cache_store = :mem_cache_store -# Enable serving of images, stylesheets, and javascripts from an asset server -# config.action_controller.asset_host = "http://assets.example.com" + # Disable Rails's static asset server + # In production, Apache or nginx will already do this + config.serve_static_assets = false -# Disable delivery errors, bad email addresses will be ignored -# config.action_mailer.raise_delivery_errors = false + # Enable serving of images, stylesheets, and javascripts from an asset server + # config.action_controller.asset_host = "http://assets.example.com" -# Enable threaded mode -# config.threadsafe! \ No newline at end of file + # Disable delivery errors, bad email addresses will be ignored + # config.action_mailer.raise_delivery_errors = false + + # Enable threaded mode + # config.threadsafe! +end diff --git a/config/environments/test.rb b/config/environments/test.rb index d6f80a40..4e5cb49d 100644 --- a/config/environments/test.rb +++ b/config/environments/test.rb @@ -1,28 +1,29 @@ -# Settings specified here will take precedence over those in config/environment.rb +R4::Application.configure do + # Settings specified here will take precedence over those in config/environment.rb -# The test environment is used exclusively to run your application's -# test suite. You never need to work with it otherwise. Remember that -# your test database is "scratch space" for the test suite and is wiped -# and recreated between test runs. Don't rely on the data there! -config.cache_classes = true + # The test environment is used exclusively to run your application's + # test suite. You never need to work with it otherwise. Remember that + # your test database is "scratch space" for the test suite and is wiped + # and recreated between test runs. Don't rely on the data there! + config.cache_classes = true -# Log error messages when you accidentally call methods on nil. -config.whiny_nils = true + # Log error messages when you accidentally call methods on nil. + config.whiny_nils = true -# Show full error reports and disable caching -config.action_controller.consider_all_requests_local = true -config.action_controller.perform_caching = false -config.action_view.cache_template_loading = true + # Show full error reports and disable caching + config.consider_all_requests_local = true + config.action_controller.perform_caching = false -# Disable request forgery protection in test environment -config.action_controller.allow_forgery_protection = false + # Disable request forgery protection in test environment + config.action_controller.allow_forgery_protection = false -# Tell Action Mailer not to deliver emails to the real world. -# The :test delivery method accumulates sent emails in the -# ActionMailer::Base.deliveries array. -config.action_mailer.delivery_method = :test + # Tell Action Mailer not to deliver emails to the real world. + # The :test delivery method accumulates sent emails in the + # ActionMailer::Base.deliveries array. + config.action_mailer.delivery_method = :test -# Use SQL instead of Active Record's schema dumper when creating the test database. -# This is necessary if your schema can't be completely dumped by the schema dumper, -# like if you have constraints or database-specific column types -# config.active_record.schema_format = :sql \ No newline at end of file + # Use SQL instead of Active Record's schema dumper when creating the test database. + # This is necessary if your schema can't be completely dumped by the schema dumper, + # like if you have constraints or database-specific column types + # config.active_record.schema_format = :sql +end diff --git a/config/initializers/backtrace_silencers.rb b/config/initializers/backtrace_silencers.rb index c2169ed0..59385cdf 100644 --- a/config/initializers/backtrace_silencers.rb +++ b/config/initializers/backtrace_silencers.rb @@ -3,5 +3,5 @@ # You can add backtrace silencers for libraries that you're using but don't wish to see in your backtraces. # Rails.backtrace_cleaner.add_silencer { |line| line =~ /my_noisy_library/ } -# You can also remove all the silencers if you're trying do debug a problem that might steem from framework code. -# Rails.backtrace_cleaner.remove_silencers! \ No newline at end of file +# You can also remove all the silencers if you're trying to debug a problem that might stem from framework code. +# Rails.backtrace_cleaner.remove_silencers! diff --git a/config/initializers/cookie_verification_secret.rb b/config/initializers/cookie_verification_secret.rb new file mode 100644 index 00000000..9bcdd436 --- /dev/null +++ b/config/initializers/cookie_verification_secret.rb @@ -0,0 +1,7 @@ +# Be sure to restart your server when you modify this file. + +# Your secret key for verifying the integrity of signed cookies. +# If you change this key, all old signed cookies will become invalid! +# Make sure the secret is at least 30 characters and all random, +# no regular words or you'll be exposed to dictionary attacks. +ActionController::Base.cookie_verifier_secret = 'cbf6409102b30cb9f4da455ee08c3a7e9d8b2a3d32a0e5b59a354dad03f469d363a8127ef4b7bc3b1afa632d7cf947a1e59e09022d2d4cd8df1f4fa521d7ec07' diff --git a/config/initializers/devise.rb b/config/initializers/devise.rb index 03d1d1b7..4d72c51c 100644 --- a/config/initializers/devise.rb +++ b/config/initializers/devise.rb @@ -2,7 +2,7 @@ # four configuration values can also be set straight in your models. Devise.setup do |config| # Configure the e-mail address which will be shown in DeviseMailer. - # config.mailer_sender = "please-change-me@config-initializers-devise.com" + config.mailer_sender = "please-change-me@config-initializers-devise.com" # ==> Configuration for :authenticatable # Invoke `rake secret` and use the printed value to setup a pepper to generate diff --git a/config/initializers/mongo.rb b/config/initializers/mongo.rb new file mode 100644 index 00000000..78b4c26f --- /dev/null +++ b/config/initializers/mongo.rb @@ -0,0 +1,28 @@ +MongoMapper.connection = Mongo::Connection.new('localhost', 27017) +MongoMapper.database = "r4-#{Rails.env}" + +if defined?(PhusionPassenger) + PhusionPassenger.on_event(:starting_worker_process) do |forked| + MongoMapper.connection.connect_to_master if forked + end +end + +module MongoMapper::Document::ClassMethods + + def key_i18n(key, *options) + VALID_LOCALES.each do |locale| + key "#{key.to_s}_#{locale}".to_sym, *options + end + + define_method(key) do + self.send("#{key.to_s}_#{I18n.locale}") + end + + define_method("#{key}=") do |value| + VALID_LOCALES.each do |locale| + self.send("#{key.to_s}_#{locale}=", value) + end + end + end + +end \ No newline at end of file diff --git a/config/initializers/session_store.rb b/config/initializers/session_store.rb index 42bb2dd9..37ae2d7c 100644 --- a/config/initializers/session_store.rb +++ b/config/initializers/session_store.rb @@ -5,8 +5,8 @@ # Make sure the secret is at least 30 characters and all random, # no regular words or you'll be exposed to dictionary attacks. ActionController::Base.session = { - :key => '_r4_session', - :secret => '1f062d6db3c797bea2da1ae0c82c0dd952833633fcfdda1e20baca0686bc2bee75aaa0db9ffe67e44655fad008fd1ddc5d670b051c7cf54ac6fa51c16dbe49fd' + :key => '_r4_session', + :secret => '3de7e1b7f4a979950642fd6ebf1a1f67488c568c7e510d7fe9011d6f8ad37e4195bc32aed07167ac7541b7b152d4ffbca73e05bd19d8faddff52b422f3851890' } # Use the database for sessions instead of the cookie-based default, diff --git a/config/locales/devise.en.yml b/config/locales/devise.en.yml index 3428bf06..2887aa3a 100644 --- a/config/locales/devise.en.yml +++ b/config/locales/devise.en.yml @@ -1,4 +1,10 @@ en: + errors: + messages: + not_found: "not found" + already_confirmed: "was already confirmed" + not_locked: "was not locked" + devise: sessions: link: 'Sign in' diff --git a/config/locales/en.yml b/config/locales/en.yml index f265c068..a747bfa6 100644 --- a/config/locales/en.yml +++ b/config/locales/en.yml @@ -2,4 +2,4 @@ # See http://github.com/svenfuchs/rails-i18n/tree/master/rails%2Flocale for starting points. en: - hello: "Hello world" \ No newline at end of file + hello: "Hello world" diff --git a/config/routes.rb b/config/routes.rb index d35cb85c..ddc701f6 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -1,66 +1,90 @@ -ActionController::Routing::Routes.draw do |map| +R4::Application.routes.draw do |map| - map.resources :announcements + resources :announcements - map.namespace :admin do |admin| - admin.resources :items, :member => { :up => :put, :down => :put } - admin.resources :pages - admin.resources :links - admin.resources :components - admin.resources :layouts - admin.resources :snippets - admin.resources :assets - end + namespace :admin do + resources :items do + member do + put :up + put :down + end + + end + + resources :pages + resources :links + resources :components + resources :layouts + resources :snippets + resources :assets + end + + namespace :panel do + resources :users + resources :announcements + end + + devise_for :users +# match 'users' => '#index', :as => :devise_for + match '/' => 'pages#index' + match '*page_name' => 'pages#show', :as => :page - map.namespace :panel do |panel| - panel.resources :users - panel.resources :announcements - end + - map.devise_for :users - - # The priority is based upon order of creation: first created -> highest priority. + # The priority is based upon order of creation: + # first created -> highest priority. # Sample of regular route: - # map.connect 'products/:id', :controller => 'catalog', :action => 'view' + # match 'products/:id' => 'catalog#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' + # 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): - # map.resources :products + # resources :products # Sample resource route with options: - # map.resources :products, :member => { :short => :get, :toggle => :post }, :collection => { :sold => :get } + # resources :products do + # member do + # get :short + # post :toggle + # end + # + # collection do + # get :sold + # end + # end # Sample resource route with sub-resources: - # map.resources :products, :has_many => [ :comments, :sales ], :has_one => :seller - + # resources :products do + # resources :comments, :sales + # resource :seller + # end + # Sample resource route with more complex sub-resources - # map.resources :products do |products| - # products.resources :comments - # products.resources :sales, :collection => { :recent => :get } + # resources :products do + # resources :comments + # resources :sales do + # get :recent, :on => :collection + # end # 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 + # 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 map.root -- just remember to delete public/index.html. - map.root :controller => "pages" + # You can have the root of your site routed with "root" + # just remember to delete public/index.html. + root :to => "pages#index" # 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 the them or commenting them out if you're using named routes and resources. - - map.page '*page_name', :controller => 'pages', :action => 'show' - - #map.connect ':controller/:action/:id' - #map.connect ':controller/:action/:id.:format' + # 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 diff --git a/db/seeds.rb b/db/seeds.rb new file mode 100644 index 00000000..664d8c74 --- /dev/null +++ b/db/seeds.rb @@ -0,0 +1,7 @@ +# This file should contain all the record creation needed to seed the database with its default values. +# The data can then be loaded with the rake db:seed (or created alongside the db with db:setup). +# +# Examples: +# +# cities = City.create([{ :name => 'Chicago' }, { :name => 'Copenhagen' }]) +# Mayor.create(:name => 'Daley', :city => cities.first) diff --git a/public/404.html b/public/404.html index eff660b9..9a48320a 100644 --- a/public/404.html +++ b/public/404.html @@ -1,23 +1,19 @@ - - - - + +
-You may have mistyped the address or the page may have moved.
- \ No newline at end of file + diff --git a/public/422.html b/public/422.html index b54e4a3c..83660ab1 100644 --- a/public/422.html +++ b/public/422.html @@ -1,23 +1,19 @@ - - - - + + -Maybe you tried to change something you didn't have access to.
- \ No newline at end of file + diff --git a/public/500.html b/public/500.html index ec3bbf02..b80307fc 100644 --- a/public/500.html +++ b/public/500.html @@ -1,23 +1,19 @@ - - - - + + -