Class: Mercury::Generators::Install::ImagesGenerator
- Inherits:
-
Rails::Generators::Base
- Object
- Rails::Generators::Base
- Mercury::Generators::Install::ImagesGenerator
- Includes:
- Rails::Generators::Migration
- Defined in:
- lib/generators/mercury/install/images/images_generator.rb
Class Method Summary collapse
-
.next_migration_number(dirname) ⇒ Object
Implement the required interface for Rails::Generators::Migration.
Instance Method Summary collapse
- #add_gemfile_dependencies ⇒ Object
- #add_routes ⇒ Object
- #copy_controller ⇒ Object
- #copy_models ⇒ Object
Class Method Details
.next_migration_number(dirname) ⇒ Object
Implement the required interface for Rails::Generators::Migration.
41 42 43 |
# File 'lib/generators/mercury/install/images/images_generator.rb', line 41 def self.next_migration_number(dirname) #:nodoc: ActiveRecord::Generators::Base.next_migration_number(dirname) end |
Instance Method Details
#add_gemfile_dependencies ⇒ Object
33 34 35 36 37 38 |
# File 'lib/generators/mercury/install/images/images_generator.rb', line 33 def add_gemfile_dependencies append_to_file "Gemfile", %Q{gem 'paperclip'} if [:orm] == 'mongoid' append_to_file "Gemfile", %Q{gem 'mongoid-paperclip', :require => 'mongoid_paperclip'} end end |
#add_routes ⇒ Object
27 28 29 30 31 |
# File 'lib/generators/mercury/install/images/images_generator.rb', line 27 def add_routes route %Q{ namespace :mercury do resources :images end} end |
#copy_controller ⇒ Object
23 24 25 |
# File 'lib/generators/mercury/install/images/images_generator.rb', line 23 def copy_controller copy_file 'images_controller.rb', 'app/controllers/mercury/images_controller.rb' end |
#copy_models ⇒ Object
14 15 16 17 18 19 20 21 |
# File 'lib/generators/mercury/install/images/images_generator.rb', line 14 def copy_models if [:orm] == 'mongoid' copy_file 'mongoid_paperclip_image.rb', 'app/models/mercury/image.rb' else copy_file 'ar_paperclip_image.rb', 'app/models/mercury/image.rb' migration_template 'ar_paperclip_image_migration.rb', 'db/migrate/create_mercury_images.rb' end end |