Ruby on Rails | Screencasts | Download | Documentation | Weblog | Community | Source

Changeset 6069

Show
Ignore:
Timestamp:
01/28/07 13:55:39 (3 years ago)
Author:
bitsweat
Message:

Resource generator depends on the model generator rather than duplicating it. Closes #7269.

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • trunk/railties/CHANGELOG

    r6016 r6069  
    11*SVN* 
     2 
     3* Resource generator depends on the model generator rather than duplicating it.  #7269 [bscofield] 
    24 
    35* Add/Update usage documentation for script/destroy, resource generator and scaffold_resource generator.  Closes #7092, #7271, #7267.  [bscofield] 
  • trunk/railties/lib/rails_generator/generators/components/resource/resource_generator.rb

    r5379 r6069  
    4040      m.directory(File.join('test/unit', class_path)) 
    4141 
    42       m.template('model.rb', File.join('app/models', class_path, "#{file_name}.rb")) 
     42      m.dependency 'model', [singular_name] + @args, :collision => :skip 
    4343 
    4444      m.template( 
     
    4848      m.template('functional_test.rb', File.join('test/functional', controller_class_path, "#{controller_file_name}_controller_test.rb")) 
    4949      m.template('helper.rb',          File.join('app/helpers',     controller_class_path, "#{controller_file_name}_helper.rb")) 
    50       m.template('unit_test.rb',       File.join('test/unit',       class_path, "#{file_name}_test.rb")) 
    51       m.template('fixtures.yml',       File.join('test/fixtures', "#{table_name}.yml")) 
    52  
    53       unless options[:skip_migration] 
    54         m.migration_template( 
    55           'migration.rb', 'db/migrate',  
    56           :assigns => { 
    57             :migration_name => "Create#{class_name.pluralize.gsub(/::/, '')}", 
    58             :attributes     => attributes 
    59           },  
    60           :migration_file_name => "create_#{file_path.gsub(/\//, '_').pluralize}" 
    61         ) 
    62       end 
    6350 
    6451      m.route_resources controller_file_name 
  • trunk/railties/lib/rails_generator/generators/components/resource/templates/fixtures.yml

    r5236 r6069  
    1 # Read about fixtures at http://ar.rubyonrails.org/classes/Fixtures.html 
    2 one: 
    3   id: 1 
    4 <% for attribute in attributes -%> 
    5   <%= attribute.name %>: <%= attribute.default %> 
    6 <% end -%> 
    7 two: 
    8   id: 2 
    9 <% for attribute in attributes -%> 
    10   <%= attribute.name %>: <%= attribute.default %> 
    11 <% end -%> 
  • trunk/railties/lib/rails_generator/generators/components/resource/templates/migration.rb

    r5236 r6069  
    1 class <%= migration_name %> < ActiveRecord::Migration 
    2   def self.up 
    3     create_table :<%= table_name %> do |t| 
    4 <% for attribute in attributes -%> 
    5       t.column :<%= attribute.name %>, :<%= attribute.type %> 
    6 <% end -%> 
    7     end 
    8   end 
    9  
    10   def self.down 
    11     drop_table :<%= table_name %> 
    12   end 
    13 end 
  • trunk/railties/lib/rails_generator/generators/components/resource/templates/model.rb

    r5236 r6069  
    1 class <%= class_name %> < ActiveRecord::Base 
    2 end 
  • trunk/railties/lib/rails_generator/generators/components/resource/templates/unit_test.rb

    r5236 r6069  
    1 require File.dirname(__FILE__) + '<%= '/..' * class_nesting_depth %>/../test_helper' 
    2  
    3 class <%= class_name %>Test < Test::Unit::TestCase 
    4   fixtures :<%= table_name %> 
    5  
    6   # Replace this with your real tests. 
    7   def test_truth 
    8     assert true 
    9   end 
    10 end