Class: HtmlBlocksGenerator

Inherits:
Rails::Generators::NamedBase
  • Object
show all
Includes:
Rails::Generators::Migration
Defined in:
lib/generators/html_blocks_generator.rb

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.next_migration_number(path) ⇒ Object



9
10
11
12
13
14
15
# File 'lib/generators/html_blocks_generator.rb', line 9

def self.next_migration_number(path)
  if ActiveRecord::Base.timestamped_migrations
    Time.now.utc.strftime("%Y%m%d%H%M%S")
  else
    "%.3d" % (current_migration_number(dirname) + 1)
  end
end

Instance Method Details

#add_controllerObject



39
40
41
# File 'lib/generators/html_blocks_generator.rb', line 39

def add_controller
  template 'controller.rb', "app/controllers/#{plural_file_name}_controller.rb" if options.ru?
end

#add_helperObject



35
36
37
# File 'lib/generators/html_blocks_generator.rb', line 35

def add_helper
  template 'helper.rb', "app/helpers/#{plural_file_name}_helper.rb"
end

#add_migrationObject



21
22
23
# File 'lib/generators/html_blocks_generator.rb', line 21

def add_migration
  migration_template 'migration.rb', "db/migrate/create_#{table_name}"
end

#add_modelObject



17
18
19
# File 'lib/generators/html_blocks_generator.rb', line 17

def add_model
  template 'model.rb', "app/models/#{singular_table_name}.rb"
end

#add_routeObject



43
44
45
# File 'lib/generators/html_blocks_generator.rb', line 43

def add_route
  route "resources :#{plural_name}"
end

#add_viewsObject



25
26
27
28
29
30
31
32
33
# File 'lib/generators/html_blocks_generator.rb', line 25

def add_views
  if  options.playmo? && options.ru?
    %w{_form new edit index}.each do |name|
      template "views-playmo-ru/#{name}.html.erb", "app/views/#{plural_file_name}/#{name}.html.erb"
    end
    gem "truncate_html"
    #copy_file 'gray.css', 'app/assets/stylesheets/basic/gray.css'
  end
end