Class: EasyCms::Generators::ModelGenerator
- Inherits:
-
Rails::Generators::Base
- Object
- Rails::Generators::Base
- EasyCms::Generators::ModelGenerator
- Includes:
- ResourceHelpers
- Defined in:
- lib/generators/easy_cms/model/model_generator.rb
Instance Method Summary collapse
- #add_navegation ⇒ Object
- #create_namespace ⇒ Object
- #generate_model_controller ⇒ Object
- #generate_model_layouts ⇒ Object
- #generate_route ⇒ Object
Instance Method Details
#add_navegation ⇒ Object
22 23 24 25 |
# File 'lib/generators/easy_cms/model/model_generator.rb', line 22 def add_navegation path = build_path("easy_cms/model/templates/layouts/item_navegation.html.erb") insert_into_file "app/views/layouts/#{namespace}.html.erb", read_file(path), :after => "<!-- Easy CMS - nav - don't delete this line -->\n" end |
#create_namespace ⇒ Object
13 14 15 |
# File 'lib/generators/easy_cms/model/model_generator.rb', line 13 def create_namespace generate "easy_cms:namespace #{namespace}" end |
#generate_model_controller ⇒ Object
17 18 19 20 |
# File 'lib/generators/easy_cms/model/model_generator.rb', line 17 def generate_model_controller file_name = "app/controllers/#{namespace}/#{model.pluralize}_controller.rb" template './controllers/model_controller.erb', file_name, end |
#generate_model_layouts ⇒ Object
27 28 29 30 31 32 33 |
# File 'lib/generators/easy_cms/model/model_generator.rb', line 27 def generate_model_layouts generate_action_layout('index') generate_action_layout('show') generate_action_layout('new') generate_action_layout('edit') generate_action_layout('_form') end |
#generate_route ⇒ Object
35 36 37 38 |
# File 'lib/generators/easy_cms/model/model_generator.rb', line 35 def generate_route easy_cms_route = %Q(namespace :#{namespace} do\n resources :#{model.pluralize}\n end) route easy_cms_route end |