Sha256: 785e262cc26fd31f84a231c79ac79c182ba80acce93b06cdc16db92365ae0da9
Contents?: true
Size: 1.74 KB
Versions: 7
Compression:
Stored size: 1.74 KB
Contents
module Hobo class FrontControllerGenerator < Rails::Generators::NamedBase source_root File.expand_path('../templates', __FILE__) # overrides the default argument :name, :type => :string, :default => 'front', :optional => true include Generators::Hobo::Controller include Generators::Hobo::InviteOnly def self.banner "rails generate hobo:front_controller [NAME=front] [options]" end class_option :add_routes, :type => :boolean, :desc => "Modify config/routes.rb to support the front controller", :default => true class_option :delete_index, :aliases => '-d', :type => :boolean, :desc => "Delete public/index.html", :default => true class_option :user_resource_name, :type => :string, :desc => "User Resource Name", :default => 'user' def generate_controller template 'controller.rb.erb', File.join('app/controllers',"#{file_path}_controller.rb") end def generate_index_and_summary template("index.dryml", File.join('app/views', file_path, "index.dryml")) template("summary.dryml", File.join('app/views', file_path, "summary.dryml")) end def remove_index_html return unless options[:delete_index] remove_file File.join(Rails.root, "public/index.html") end def add_routes return unless options[:add_routes] route "match 'search' => '#{file_path}#search', :as => 'search'" if class_path.empty? route "root :to => '#{file_path}#index'" else route "match '#{file_path}' => '#{file_path}#index', :as => '#{file_path.gsub(/\//,'_')}'" end end end end
Version data entries
7 entries across 7 versions & 1 rubygems