Sha256: 6d40e82ed55a4f56fd931d815f6728b789e11e99583451cfd95806b8c698742b
Contents?: true
Size: 739 Bytes
Versions: 6
Compression:
Stored size: 739 Bytes
Contents
require 'rails/generators' # Public: Generator for admin page controllers. class AdminGenerator < Rails::Generators::NamedBase source_root File.expand_path('../templates', __FILE__) def create_admin_page_controller @controller = file_name template( 'admin_page_controller.rb.erb', "app/controllers/admin/#{@controller.underscore}_controller.rb" ) end def add_admin_route route "admin_for :#{@controller.underscore}" end def add_form_view unless Dir.exist?(Rails.root.join('app/views/admin')) Dir.mkdir(Rails.root.join('app/views/admin')) end create_file "app/views/admin/#{@controller.underscore}/_form.html.erb", <<VIEW <% # "f" is exposed as a form object %> VIEW end end
Version data entries
6 entries across 6 versions & 1 rubygems