15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
|
# File 'lib/generators/skizmo/form/form_generator.rb', line 15
def generate_form
unless nested_has_many_classes.empty?
copy_file "javascript.js", "public/javascripts/jquery.add_remove_links.js" if options.javascript?
copy_file "helper.rb", "app/helpers/add_remove_links_helper.rb" if options.helpers?
end
unless nested_classes_with_attributes.empty? and non_nested_has_many_classes.empty? and non_nested_belongs_to_classes.empty?
template "setup_helper.rb", "app/helpers/#{file_name}_setup_helper.rb" if options.helpers?
end
template "index.html.#{engine}", "app/views/#{file_name.pluralize}/index.html.#{engine}" if options.index_view?
template "new.html.#{engine}", "app/views/#{file_name.pluralize}/new.html.#{engine}"
template "edit.html.#{engine}", "app/views/#{file_name.pluralize}/edit.html.#{engine}"
@have_attachment_string = have_attachments? ? ", :html => { :multipart => true }" : ""
template "_form.html.#{engine}", "app/views/#{file_name.pluralize}/_form.html.#{engine}"
nested_classes_with_attributes.each do |hash_with_kls_and_attrs|
@kls = hash_with_kls_and_attrs[:kls] @sym = hash_with_kls_and_attrs[:sym] @attrs = hash_with_kls_and_attrs[:attrs] @assoc = hash_with_kls_and_attrs[:assoc] template "_nested_fields.html.#{engine}", "app/views/#{file_name.pluralize}/_#{@sym.to_s.singularize}_fields.html.#{engine}"
end
end
|