Class: SuperuserGenerator
- Inherits:
-
Rails::Generators::Base
- Object
- Rails::Generators::Base
- SuperuserGenerator
- Defined in:
- lib/generators/superuser/superuser_generator.rb
Instance Attribute Summary collapse
-
#attributes ⇒ Object
Returns the value of attribute attributes.
Instance Method Summary collapse
-
#generate_controller ⇒ Object
NOTE: the order of the following methods is important!.
- #generate_route_and_link ⇒ Object
- #generate_views ⇒ Object
Instance Attribute Details
#attributes ⇒ Object
Returns the value of attribute attributes.
5 6 7 |
# File 'lib/generators/superuser/superuser_generator.rb', line 5 def attributes @attributes end |
Instance Method Details
#generate_controller ⇒ Object
NOTE: the order of the following methods is important!
9 10 11 |
# File 'lib/generators/superuser/superuser_generator.rb', line 9 def generate_controller template "controller_template.rb", "app/controllers/superuser/#{naming(:resources)}_controller.rb" end |
#generate_route_and_link ⇒ Object
13 14 15 16 17 18 19 20 21 |
# File 'lib/generators/superuser/superuser_generator.rb', line 13 def generate_route_and_link # add resources to route if not exists route_replacement = "resources :#{resources}" r = add_resources_route 'config/routes.rb', search = 'namespace :superuser do', route_replacement # add link to resources in the layout if not exists link = "<%= link_to '#{resources}', [:superuser, :#{resources}] %>" add_layout_links 'app/views/layouts/superuser/application.html.erb', search = '<div class="sidebar_item">', link end |
#generate_views ⇒ Object
23 24 25 26 27 28 29 |
# File 'lib/generators/superuser/superuser_generator.rb', line 23 def generate_views template "views/_form.html.erb", "app/views/superuser/#{naming(:resources)}/_form.html.erb" template "views/index.html.erb", "app/views/superuser/#{naming(:resources)}/index.html.erb" template "views/show.html.erb", "app/views/superuser/#{naming(:resources)}/show.html.erb" template "views/new.html.erb", "app/views/superuser/#{naming(:resources)}/new.html.erb" template "views/edit.html.erb", "app/views/superuser/#{naming(:resources)}/edit.html.erb" end |