Class: EasyCms::Generators::ModelGenerator

Inherits:
Rails::Generators::Base
  • Object
show all
Includes:
ResourceHelpers
Defined in:
lib/generators/easy_cms/model/model_generator.rb

Instance Method Summary collapse

Instance Method Details

#add_navegationObject



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_namespaceObject



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_controllerObject



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, options_params
end

#generate_model_layoutsObject



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_routeObject



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