Sha256: 4af296aa92ff4bafdf9db56fe9051d5e58481158f2c180c82be1dfcfba69125f
Contents?: true
Size: 1.33 KB
Versions: 1
Compression:
Stored size: 1.33 KB
Contents
require 'rails/generators' module Trackman class ControllerGenerator < Rails::Generators::Base source_root File.expand_path('../templates', __FILE__) argument :controller_name, :type => :string, :default => 'errors' desc "Generates a controller to generate your static pages" @@actions = ['not_found', 'error', 'maintenance', 'maintenance_error'] @@routes = {'not-found' => 'not_found', 'error' => 'error', 'maintenance' => 'maintenance', 'maintenance-error' => 'maintenance_error'} def create_controller template "controller_layout.rb.erb", "app/controllers/#{controller_name}_controller.rb" end def create_app_config puts " ------ Trackman added \"config.exceptions_app = self.routes\" in config/application.rb ------\n" application do "config.exceptions_app = self.routes" end end def create_views create_views_for(:erb) end def create_routes @@routes.each do |k, v| route "match \"/#{k}\", :to => \"#{controller_name}##{v}\"" end end protected def create_views_for(engine) view_folder = "app/views/#{controller_name}" layout = "view_layout.html.#{engine}" @@actions.each do |n| template layout, "#{view_folder}/#{n}.html.#{engine}" end end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
trackman-0.6.1 | lib/generators/controller/controller_generator.rb |