has_defaults 0.3.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (71) hide show
  1. data/.gitignore +2 -0
  2. data/MIT-LICENSE +20 -0
  3. data/README +74 -0
  4. data/Rakefile +17 -0
  5. data/has_defaults.gemspec +19 -0
  6. data/lib/has_defaults/active_record_ext.rb +54 -0
  7. data/lib/has_defaults/version.rb +5 -0
  8. data/lib/has_defaults.rb +4 -0
  9. data/pkg/has_defaults-0.3.0.gem +0 -0
  10. data/spec/app_root/log/in_memory.log +147 -0
  11. data/spec/rails2/Gemfile +8 -0
  12. data/spec/rails2/Gemfile.lock +51 -0
  13. data/spec/rails2/Rakefile +11 -0
  14. data/spec/rails2/app_root/app/controllers/application_controller.rb +2 -0
  15. data/spec/rails2/app_root/app/models/donut.rb +21 -0
  16. data/spec/rails2/app_root/app/models/model_without_defaults.rb +2 -0
  17. data/spec/rails2/app_root/app/models/pastry.rb +6 -0
  18. data/spec/rails2/app_root/config/boot.rb +114 -0
  19. data/spec/rails2/app_root/config/database.yml +21 -0
  20. data/spec/rails2/app_root/config/environment.rb +14 -0
  21. data/spec/rails2/app_root/config/environments/in_memory.rb +0 -0
  22. data/spec/rails2/app_root/config/environments/mysql.rb +0 -0
  23. data/spec/rails2/app_root/config/environments/postgresql.rb +0 -0
  24. data/spec/rails2/app_root/config/environments/sqlite.rb +0 -0
  25. data/spec/rails2/app_root/config/environments/sqlite3.rb +0 -0
  26. data/spec/rails2/app_root/config/routes.rb +4 -0
  27. data/spec/rails2/app_root/db/migrate/001_create_pastries.rb +18 -0
  28. data/spec/rails2/app_root/db/migrate/002_create_model_without_defaults.rb +12 -0
  29. data/spec/rails2/app_root/lib/console_with_fixtures.rb +4 -0
  30. data/spec/rails2/app_root/log/.gitignore +1 -0
  31. data/spec/rails2/app_root/script/console +7 -0
  32. data/spec/rails2/has_defaults_spec.rb +79 -0
  33. data/spec/rails2/rcov.opts +2 -0
  34. data/spec/rails2/spec.opts +4 -0
  35. data/spec/rails2/spec_helper.rb +20 -0
  36. data/spec/rails3/.rspec +2 -0
  37. data/spec/rails3/Gemfile +9 -0
  38. data/spec/rails3/Gemfile.lock +101 -0
  39. data/spec/rails3/Rakefile +10 -0
  40. data/spec/rails3/app_root/.gitignore +4 -0
  41. data/spec/rails3/app_root/app/controllers/application_controller.rb +2 -0
  42. data/spec/rails3/app_root/app/models/donut.rb +21 -0
  43. data/spec/rails3/app_root/app/models/model_without_defaults.rb +2 -0
  44. data/spec/rails3/app_root/app/models/pastry.rb +6 -0
  45. data/spec/rails3/app_root/config/application.rb +32 -0
  46. data/spec/rails3/app_root/config/boot.rb +13 -0
  47. data/spec/rails3/app_root/config/database.yml +21 -0
  48. data/spec/rails3/app_root/config/environment.rb +5 -0
  49. data/spec/rails3/app_root/config/environments/in_memory.rb +0 -0
  50. data/spec/rails3/app_root/config/environments/mysql.rb +0 -0
  51. data/spec/rails3/app_root/config/environments/postgresql.rb +0 -0
  52. data/spec/rails3/app_root/config/environments/sqlite.rb +0 -0
  53. data/spec/rails3/app_root/config/environments/sqlite3.rb +0 -0
  54. data/spec/rails3/app_root/config/environments/test.rb +35 -0
  55. data/spec/rails3/app_root/config/initializers/backtrace_silencers.rb +7 -0
  56. data/spec/rails3/app_root/config/initializers/inflections.rb +10 -0
  57. data/spec/rails3/app_root/config/initializers/mime_types.rb +5 -0
  58. data/spec/rails3/app_root/config/initializers/secret_token.rb +7 -0
  59. data/spec/rails3/app_root/config/initializers/session_store.rb +8 -0
  60. data/spec/rails3/app_root/config/locales/en.yml +5 -0
  61. data/spec/rails3/app_root/config/routes.rb +58 -0
  62. data/spec/rails3/app_root/db/migrate/001_create_pastries.rb +18 -0
  63. data/spec/rails3/app_root/db/migrate/002_create_model_without_defaults.rb +12 -0
  64. data/spec/rails3/app_root/lib/tasks/.gitkeep +0 -0
  65. data/spec/rails3/app_root/log/.gitkeep +0 -0
  66. data/spec/rails3/app_root/script/rails +6 -0
  67. data/spec/rails3/has_defaults_spec.rb +74 -0
  68. data/spec/rails3/log/in_memory.log +33 -0
  69. data/spec/rails3/rcov.opts +2 -0
  70. data/spec/rails3/spec_helper.rb +21 -0
  71. metadata +149 -0
@@ -0,0 +1,12 @@
1
+ class CreateModelWithoutDefaults < ActiveRecord::Migration
2
+
3
+ def self.up
4
+ create_table :model_without_defaults do |t|
5
+ end
6
+ end
7
+
8
+ def self.down
9
+ drop_table :model_without_defaults
10
+ end
11
+
12
+ end
@@ -0,0 +1,4 @@
1
+ # Loads fixtures into the database when running the test app via the console
2
+ (ENV['FIXTURES'] ? ENV['FIXTURES'].split(/,/) : Dir.glob(File.join(Rails.root, '../fixtures/*.{yml,csv}'))).each do |fixture_file|
3
+ Fixtures.create_fixtures(File.join(Rails.root, '../fixtures'), File.basename(fixture_file, '.*'))
4
+ end
@@ -0,0 +1 @@
1
+ *.log
@@ -0,0 +1,7 @@
1
+ irb = RUBY_PLATFORM =~ /(:?mswin|mingw)/ ? 'irb.bat' : 'irb'
2
+ libs = " -r irb/completion"
3
+ libs << " -r test/test_helper"
4
+ libs << " -r console_app"
5
+ libs << " -r console_with_helpers"
6
+ libs << " -r console_with_fixtures"
7
+ exec "#{irb} #{libs} --simple-prompt"
@@ -0,0 +1,79 @@
1
+ require File.dirname(__FILE__) + "/spec_helper"
2
+
3
+ describe "has_defaults" do
4
+
5
+ context "given a model with defaults" do
6
+
7
+ it "should set defaults" do
8
+ new_donut = Donut.new
9
+ new_donut.flavor.should == "cream"
10
+ new_donut.name.should == "Cream"
11
+ end
12
+
13
+ it "should use setters methods to set the defaults" do
14
+ new_donut = Donut.new
15
+ new_donut.instance_variable_get('@flavor_setter_called').should be_true
16
+ end
17
+
18
+ it "should call procs in the model context when given as defaults" do
19
+ new_donut = Donut.new
20
+ new_donut.weight.should == 'a lot'
21
+ end
22
+
23
+ it "should merge multiple has_defaults directives" do
24
+ new_donut = Donut.new
25
+ new_donut.maker.should == "Dunkin Donuts"
26
+ end
27
+
28
+ it "should set defaults only if attributes are nil" do
29
+ donut = Donut.new(:flavor => 'vanilla')
30
+ donut.flavor.should == "vanilla"
31
+ end
32
+
33
+ it "should not set a default on an attribute that is set to an empty string" do
34
+ donut = Donut.new(:flavor => '')
35
+ donut.flavor.should == ''
36
+ end
37
+
38
+ it "should use getters methods to check if an attribute is nil" do
39
+ new_donut = Donut.new
40
+ new_donut.instance_variable_get('@flavor_getter_called').should be_true
41
+ end
42
+
43
+ it "should return default value for an attribute" do
44
+ Donut.new.default_for(:flavor).should == "cream"
45
+ end
46
+
47
+ it "should not set defaults when loading a saved record" do
48
+ Donut.create(:flavor => "vanilla")
49
+ Donut.first.flavor.should == "vanilla"
50
+ end
51
+
52
+ it "should define #after_initialize" do
53
+ donut = Donut.new
54
+ donut.should respond_to(:after_initialize)
55
+ end
56
+
57
+ it "should not redefine defaults in its superclass" do
58
+ pastry = Pastry.new
59
+ pastry.maker.should == 'Mom'
60
+ pastry.default_for(:maker).should == 'Mom'
61
+ end
62
+
63
+ it "should respect defaults from its superclass" do
64
+ donut = Donut.create
65
+ donut.main_ingredient.should == 'flour'
66
+ donut.maker.should_not == 'Mom'
67
+ end
68
+
69
+ end
70
+
71
+ context "given a model without defaults" do
72
+
73
+ it "should not define #after_initialize so initialization remains fast" do
74
+ ModelWithoutDefaults.new.should_not respond_to(:after_initialize)
75
+ end
76
+
77
+ end
78
+
79
+ end
@@ -0,0 +1,2 @@
1
+ --exclude "spec/*,gems/*"
2
+ --rails
@@ -0,0 +1,4 @@
1
+ --colour
2
+ --format progress
3
+ --loadby mtime
4
+ --reverse
@@ -0,0 +1,20 @@
1
+ $: << File.join(File.dirname(__FILE__), "/../lib" )
2
+
3
+ # Set the default environment to sqlite3's in_memory database
4
+ ENV['RAILS_ENV'] ||= 'in_memory'
5
+
6
+ # Load the Rails environment and testing framework
7
+ require "#{File.dirname(__FILE__)}/app_root/config/environment"
8
+ require "#{File.dirname(__FILE__)}/../../lib/has_defaults"
9
+ require 'spec/rails'
10
+
11
+ # Undo changes to RAILS_ENV
12
+ silence_warnings {RAILS_ENV = ENV['RAILS_ENV']}
13
+
14
+ # Run the migrations
15
+ ActiveRecord::Migrator.migrate("#{Rails.root}/db/migrate")
16
+
17
+ Spec::Runner.configure do |config|
18
+ config.use_transactional_fixtures = true
19
+ config.use_instantiated_fixtures = false
20
+ end
@@ -0,0 +1,2 @@
1
+ --colour
2
+ --format progress
@@ -0,0 +1,9 @@
1
+ source 'http://rubygems.org'
2
+
3
+ gem 'sqlite3'
4
+ gem 'rails', '=3.0.3'
5
+ gem 'rspec'
6
+ gem 'rspec-rails'
7
+ gem 'ruby-debug'
8
+ gem 'has_defaults', :path => '../..'
9
+
@@ -0,0 +1,101 @@
1
+ PATH
2
+ remote: ../..
3
+ specs:
4
+ has_defaults (0.3.0)
5
+ rspec
6
+
7
+ GEM
8
+ remote: http://rubygems.org/
9
+ specs:
10
+ abstract (1.0.0)
11
+ actionmailer (3.0.3)
12
+ actionpack (= 3.0.3)
13
+ mail (~> 2.2.9)
14
+ actionpack (3.0.3)
15
+ activemodel (= 3.0.3)
16
+ activesupport (= 3.0.3)
17
+ builder (~> 2.1.2)
18
+ erubis (~> 2.6.6)
19
+ i18n (~> 0.4)
20
+ rack (~> 1.2.1)
21
+ rack-mount (~> 0.6.13)
22
+ rack-test (~> 0.5.6)
23
+ tzinfo (~> 0.3.23)
24
+ activemodel (3.0.3)
25
+ activesupport (= 3.0.3)
26
+ builder (~> 2.1.2)
27
+ i18n (~> 0.4)
28
+ activerecord (3.0.3)
29
+ activemodel (= 3.0.3)
30
+ activesupport (= 3.0.3)
31
+ arel (~> 2.0.2)
32
+ tzinfo (~> 0.3.23)
33
+ activeresource (3.0.3)
34
+ activemodel (= 3.0.3)
35
+ activesupport (= 3.0.3)
36
+ activesupport (3.0.3)
37
+ arel (2.0.4)
38
+ builder (2.1.2)
39
+ columnize (0.3.2)
40
+ diff-lcs (1.1.2)
41
+ erubis (2.6.6)
42
+ abstract (>= 1.0.0)
43
+ i18n (0.4.2)
44
+ linecache (0.43)
45
+ mail (2.2.10)
46
+ activesupport (>= 2.3.6)
47
+ i18n (~> 0.4.1)
48
+ mime-types (~> 1.16)
49
+ treetop (~> 1.4.8)
50
+ mime-types (1.16)
51
+ polyglot (0.3.1)
52
+ rack (1.2.1)
53
+ rack-mount (0.6.13)
54
+ rack (>= 1.0.0)
55
+ rack-test (0.5.6)
56
+ rack (>= 1.0)
57
+ rails (3.0.3)
58
+ actionmailer (= 3.0.3)
59
+ actionpack (= 3.0.3)
60
+ activerecord (= 3.0.3)
61
+ activeresource (= 3.0.3)
62
+ activesupport (= 3.0.3)
63
+ bundler (~> 1.0)
64
+ railties (= 3.0.3)
65
+ railties (3.0.3)
66
+ actionpack (= 3.0.3)
67
+ activesupport (= 3.0.3)
68
+ rake (>= 0.8.7)
69
+ thor (~> 0.14.4)
70
+ rake (0.8.7)
71
+ rspec (2.1.0)
72
+ rspec-core (~> 2.1.0)
73
+ rspec-expectations (~> 2.1.0)
74
+ rspec-mocks (~> 2.1.0)
75
+ rspec-core (2.1.0)
76
+ rspec-expectations (2.1.0)
77
+ diff-lcs (~> 1.1.2)
78
+ rspec-mocks (2.1.0)
79
+ rspec-rails (2.1.0)
80
+ rspec (~> 2.1.0)
81
+ ruby-debug (0.10.4)
82
+ columnize (>= 0.1)
83
+ ruby-debug-base (~> 0.10.4.0)
84
+ ruby-debug-base (0.10.4)
85
+ linecache (>= 0.3)
86
+ sqlite3 (1.3.6)
87
+ thor (0.14.6)
88
+ treetop (1.4.9)
89
+ polyglot (>= 0.3.1)
90
+ tzinfo (0.3.23)
91
+
92
+ PLATFORMS
93
+ ruby
94
+
95
+ DEPENDENCIES
96
+ has_defaults!
97
+ rails (= 3.0.3)
98
+ rspec
99
+ rspec-rails
100
+ ruby-debug
101
+ sqlite3
@@ -0,0 +1,10 @@
1
+ require 'rake'
2
+ require 'rspec/core/rake_task'
3
+
4
+ desc 'Default: Run all specs for a specific rails version.'
5
+ task :default => :spec
6
+
7
+ desc "Run all specs for a specific rails version"
8
+ RSpec::Core::RakeTask.new(:spec) do |t|
9
+ t.pattern = '**/*_spec.rb'
10
+ end
@@ -0,0 +1,4 @@
1
+ .bundle
2
+ db/*.sqlite3
3
+ log/*.log
4
+ tmp/**/*
@@ -0,0 +1,2 @@
1
+ class ApplicationController < ActionController::Base
2
+ end
@@ -0,0 +1,21 @@
1
+ class Donut < Pastry
2
+
3
+ has_defaults :flavor => "cream", :name => "Cream"
4
+ has_defaults :maker => proc { "Dunkin Donuts" }
5
+ has_defaults :weight => proc { weigh }
6
+
7
+ def flavor
8
+ @flavor_getter_called = true
9
+ read_attribute(:flavor)
10
+ end
11
+
12
+ def flavor=(value)
13
+ @flavor_setter_called = true
14
+ write_attribute(:flavor, value)
15
+ end
16
+
17
+ def weigh
18
+ "a lot"
19
+ end
20
+
21
+ end
@@ -0,0 +1,2 @@
1
+ class ModelWithoutDefaults < ActiveRecord::Base
2
+ end
@@ -0,0 +1,6 @@
1
+ class Pastry < ActiveRecord::Base
2
+
3
+ has_defaults :main_ingredient => "flour", :maker => "Mom"
4
+
5
+ end
6
+
@@ -0,0 +1,32 @@
1
+ require File.expand_path('../boot', __FILE__)
2
+
3
+ require 'rails/all'
4
+
5
+ # If you have a Gemfile, require the gems listed there, including any gems
6
+ # you've limited to :test, :development, or :production.
7
+ Bundler.require(:default, Rails.env) if defined?(Bundler)
8
+
9
+
10
+ module HasDefaultSpecApp
11
+ class Application < Rails::Application
12
+ config.encoding = "utf-8"
13
+
14
+ config.cache_classes = true
15
+ config.whiny_nils = true
16
+
17
+ config.consider_all_requests_local = true
18
+ config.action_controller.perform_caching = false
19
+
20
+ config.action_dispatch.show_exceptions = false
21
+
22
+ config.action_controller.allow_forgery_protection = false
23
+
24
+ config.action_mailer.delivery_method = :test
25
+
26
+ config.active_support.deprecation = :stderr
27
+
28
+ config.root = File.expand_path('../..', __FILE__)
29
+
30
+ railties.plugins << Rails::Plugin.new(File.expand_path('../../../../..', __FILE__))
31
+ end
32
+ end
@@ -0,0 +1,13 @@
1
+ require 'rubygems'
2
+
3
+ # Set up gems listed in the Gemfile.
4
+ gemfile = File.expand_path('../../Gemfile', __FILE__)
5
+ begin
6
+ ENV['BUNDLE_GEMFILE'] = gemfile
7
+ require 'bundler'
8
+ Bundler.setup
9
+ rescue Bundler::GemNotFound => e
10
+ STDERR.puts e.message
11
+ STDERR.puts "Try running `bundle install`."
12
+ exit!
13
+ end if File.exist?(gemfile)
@@ -0,0 +1,21 @@
1
+ in_memory:
2
+ adapter: sqlite3
3
+ database: ":memory:"
4
+ verbosity: quiet
5
+ sqlite:
6
+ adapter: sqlite
7
+ dbfile: plugin_test.sqlite.db
8
+ sqlite3:
9
+ adapter: sqlite3
10
+ dbfile: plugin_test.sqlite3.db
11
+ postgresql:
12
+ adapter: postgresql
13
+ username: postgres
14
+ password: postgres
15
+ database: plugin_test
16
+ mysql:
17
+ adapter: mysql
18
+ host: localhost
19
+ username: root
20
+ password:
21
+ database: plugin_test
@@ -0,0 +1,5 @@
1
+ # Load the rails application
2
+ require File.expand_path('../application', __FILE__)
3
+
4
+ # Initialize the rails application
5
+ HasDefaultSpecApp::Application.initialize!
File without changes
@@ -0,0 +1,35 @@
1
+ HasDefaultSpecApp::Application.configure do
2
+ # Settings specified here will take precedence over those in config/application.rb
3
+
4
+ # The test environment is used exclusively to run your application's
5
+ # test suite. You never need to work with it otherwise. Remember that
6
+ # your test database is "scratch space" for the test suite and is wiped
7
+ # and recreated between test runs. Don't rely on the data there!
8
+ config.cache_classes = true
9
+
10
+ # Log error messages when you accidentally call methods on nil.
11
+ config.whiny_nils = true
12
+
13
+ # Show full error reports and disable caching
14
+ config.consider_all_requests_local = true
15
+ config.action_controller.perform_caching = false
16
+
17
+ # Raise exceptions instead of rendering exception templates
18
+ config.action_dispatch.show_exceptions = false
19
+
20
+ # Disable request forgery protection in test environment
21
+ config.action_controller.allow_forgery_protection = false
22
+
23
+ # Tell Action Mailer not to deliver emails to the real world.
24
+ # The :test delivery method accumulates sent emails in the
25
+ # ActionMailer::Base.deliveries array.
26
+ config.action_mailer.delivery_method = :test
27
+
28
+ # Use SQL instead of Active Record's schema dumper when creating the test database.
29
+ # This is necessary if your schema can't be completely dumped by the schema dumper,
30
+ # like if you have constraints or database-specific column types
31
+ # config.active_record.schema_format = :sql
32
+
33
+ # Print deprecation notices to the stderr
34
+ config.active_support.deprecation = :stderr
35
+ end
@@ -0,0 +1,7 @@
1
+ # Be sure to restart your server when you modify this file.
2
+
3
+ # You can add backtrace silencers for libraries that you're using but don't wish to see in your backtraces.
4
+ # Rails.backtrace_cleaner.add_silencer { |line| line =~ /my_noisy_library/ }
5
+
6
+ # You can also remove all the silencers if you're trying to debug a problem that might stem from framework code.
7
+ # Rails.backtrace_cleaner.remove_silencers!
@@ -0,0 +1,10 @@
1
+ # Be sure to restart your server when you modify this file.
2
+
3
+ # Add new inflection rules using the following format
4
+ # (all these examples are active by default):
5
+ # ActiveSupport::Inflector.inflections do |inflect|
6
+ # inflect.plural /^(ox)$/i, '\1en'
7
+ # inflect.singular /^(ox)en/i, '\1'
8
+ # inflect.irregular 'person', 'people'
9
+ # inflect.uncountable %w( fish sheep )
10
+ # end
@@ -0,0 +1,5 @@
1
+ # Be sure to restart your server when you modify this file.
2
+
3
+ # Add new mime types for use in respond_to blocks:
4
+ # Mime::Type.register "text/richtext", :rtf
5
+ # Mime::Type.register_alias "text/html", :iphone
@@ -0,0 +1,7 @@
1
+ # Be sure to restart your server when you modify this file.
2
+
3
+ # Your secret key for verifying the integrity of signed cookies.
4
+ # If you change this key, all old signed cookies will become invalid!
5
+ # Make sure the secret is at least 30 characters and all random,
6
+ # no regular words or you'll be exposed to dictionary attacks.
7
+ HasDefaultSpecApp::Application.config.secret_token = 'cb014a08a45243e7143f31e04774c342c1fba329fd594ae1a480d8283b1a851f425dc08044311fb4be6d000b6e6681de7c76d19148419a5ffa0a9f84556d3b33'
@@ -0,0 +1,8 @@
1
+ # Be sure to restart your server when you modify this file.
2
+
3
+ HasDefaultSpecApp::Application.config.session_store :cookie_store, :key => '_app_root_session'
4
+
5
+ # Use the database for sessions instead of the cookie-based default,
6
+ # which shouldn't be used to store highly confidential information
7
+ # (create the session table with "rails generate session_migration")
8
+ # HasDefaultSpecApp::Application.config.session_store :active_record_store
@@ -0,0 +1,5 @@
1
+ # Sample localization file for English. Add more files in this directory for other locales.
2
+ # See http://github.com/svenfuchs/rails-i18n/tree/master/rails%2Flocale for starting points.
3
+
4
+ en:
5
+ hello: "Hello world"
@@ -0,0 +1,58 @@
1
+ HasDefaultSpecApp::Application.routes.draw do
2
+ # The priority is based upon order of creation:
3
+ # first created -> highest priority.
4
+
5
+ # Sample of regular route:
6
+ # match 'products/:id' => 'catalog#view'
7
+ # Keep in mind you can assign values other than :controller and :action
8
+
9
+ # Sample of named route:
10
+ # match 'products/:id/purchase' => 'catalog#purchase', :as => :purchase
11
+ # This route can be invoked with purchase_url(:id => product.id)
12
+
13
+ # Sample resource route (maps HTTP verbs to controller actions automatically):
14
+ # resources :products
15
+
16
+ # Sample resource route with options:
17
+ # resources :products do
18
+ # member do
19
+ # get 'short'
20
+ # post 'toggle'
21
+ # end
22
+ #
23
+ # collection do
24
+ # get 'sold'
25
+ # end
26
+ # end
27
+
28
+ # Sample resource route with sub-resources:
29
+ # resources :products do
30
+ # resources :comments, :sales
31
+ # resource :seller
32
+ # end
33
+
34
+ # Sample resource route with more complex sub-resources
35
+ # resources :products do
36
+ # resources :comments
37
+ # resources :sales do
38
+ # get 'recent', :on => :collection
39
+ # end
40
+ # end
41
+
42
+ # Sample resource route within a namespace:
43
+ # namespace :admin do
44
+ # # Directs /admin/products/* to Admin::ProductsController
45
+ # # (app/controllers/admin/products_controller.rb)
46
+ # resources :products
47
+ # end
48
+
49
+ # You can have the root of your site routed with "root"
50
+ # just remember to delete public/index.html.
51
+ # root :to => "welcome#index"
52
+
53
+ # See how all your routes lay out with "rake routes"
54
+
55
+ # This is a legacy wild controller route that's not recommended for RESTful applications.
56
+ # Note: This route will make all actions in every controller accessible via GET requests.
57
+ match ':controller(/:action(/:id(.:format)))'
58
+ end
@@ -0,0 +1,18 @@
1
+ class CreatePastries < ActiveRecord::Migration
2
+
3
+ def self.up
4
+ create_table :pastries do |t|
5
+ t.string :type
6
+ t.string :flavor
7
+ t.string :name
8
+ t.string :maker
9
+ t.string :weight
10
+ t.string :main_ingredient
11
+ end
12
+ end
13
+
14
+ def self.down
15
+ drop_table :pastries
16
+ end
17
+
18
+ end
@@ -0,0 +1,12 @@
1
+ class CreateModelWithoutDefaults < ActiveRecord::Migration
2
+
3
+ def self.up
4
+ create_table :model_without_defaults do |t|
5
+ end
6
+ end
7
+
8
+ def self.down
9
+ drop_table :model_without_defaults
10
+ end
11
+
12
+ end
File without changes
File without changes
@@ -0,0 +1,6 @@
1
+ #!/usr/bin/env ruby1.8
2
+ # This command will automatically be run when you run "rails" with Rails 3 gems installed from the root of your application.
3
+
4
+ APP_PATH = File.expand_path('../../config/application', __FILE__)
5
+ require File.expand_path('../../config/boot', __FILE__)
6
+ require 'rails/commands'