Class: Agile::Generators::NewFormGenerator
- Inherits:
-
Rails::Generators::NamedBase
- Object
- Rails::Generators::NamedBase
- Agile::Generators::NewFormGenerator
- Defined in:
- lib/generators/agile/new_form_generator.rb
Overview
rails g agile_rails:new_form MODEL
Class Method Summary collapse
-
.banner ⇒ Object
:nodoc:.
Instance Method Summary collapse
-
#create_form_file ⇒ Object
Will create output and save it to form filename.
Class Method Details
.banner ⇒ Object
:nodoc:
35 36 37 38 39 40 41 42 43 44 |
# File 'lib/generators/agile/new_form_generator.rb', line 35 def self. #:nodoc: <<-BANNER.chomp rails g agile_rails:new_form MODEL [options] Generates Agile Rails form for specified Rails model - options: --tabs will create form entry fields with tabs (default: --no-tabs) --extra will create some extra commented code for help (default: --no-extra) BANNER end |
Instance Method Details
#create_form_file ⇒ Object
Will create output and save it to form filename.
49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 |
# File 'lib/generators/agile/new_form_generator.rb', line 49 def create_form_file @file_name = file_name.underscore @tabs = [:tabs] pp @extra = [:extra] begin @model = @file_name.classify.constantize rescue Exception => e pp ([e.] + e.backtrace).join($/) @model = nil end return (pp "Error loading #{file_name.classify} model! Aborting.") if @model.nil? form = + + + + + create_file "app/forms/#{@file_name}.yml", form end |