class BeautifulMigrationGenerator
encoding : utf-8
Public Instance Methods
add_field_for_fulltext()
click to toggle source
# File lib/generators/beautiful_migration_generator.rb, line 23 def add_field_for_fulltext @beautiful_attributes = myattributes.dup @fulltext_field = [] myattributes.each{ |attr| a,t = attr.split(':') if ['richtext', 'wysiwyg'].include?(t) # _typetext = {bbcode|html|text|wiki|textile|markdown} # _fulltext = text without any code @fulltext_field << [a + '_typetext', 'string'].join(':') @fulltext_field << [a + '_fulltext', 'text'].join(':') end } end
add_to_model()
click to toggle source
# File lib/generators/beautiful_migration_generator.rb, line 41 def add_to_model add_relation end
generate_model()
click to toggle source
# File lib/generators/beautiful_migration_generator.rb, line 37 def generate_model generate("migration", "#{name} #{beautiful_attr_to_rails_attr.join(' ')} #{@fulltext_field.join(' ')}") end
generate_views()
click to toggle source
# File lib/generators/beautiful_migration_generator.rb, line 45 def generate_views commonpath = "app/views/#{engine_name}#{namespace_for_url}#{model_pluralize}/" # Form inject_into_file("#{commonpath}_form.html.erb", render_partial("app/views/partials/_form_field.html.erb"), :before => "<!-- Beautiful_scaffold - AddField - Do not remove -->\n" ) # Index inject_into_file("#{commonpath}index.html.erb", render_partial("app/views/partials/_index_batch.html.erb"), :before => "<!-- Beautiful_scaffold - AddField - Batch - Do not remove -->\n" ) inject_into_file("#{commonpath}index.html.erb", render_partial("app/views/partials/_index_header.html.erb"), :before => "<!-- Beautiful_scaffold - AddField - Header - Do not remove -->\n" ) inject_into_file("#{commonpath}index.html.erb", render_partial("app/views/partials/_index_column.html.erb"), :before => "<!-- Beautiful_scaffold - AddField - Column - Do not remove -->\n" ) inject_into_file("#{commonpath}index.html.erb", render_partial("app/views/partials/_index_search.html.erb"), :before => "<!-- Beautiful_scaffold - AddField - Search - Do not remove -->\n" ) inject_into_file("#{commonpath}index.html.erb", myattributes.map{ |attr| a,t = attr.split(':');"'#{a}'" }.join(',') + ',', :after => ":model_columns => [" ) # Show inject_into_file("#{commonpath}show.html.erb", render_partial("app/views/partials/_show_field.html.erb"), :before => "<!-- Beautiful_scaffold - AddField - Field - Do not remove -->\n" ) end
install_gems()
click to toggle source
# File lib/generators/beautiful_migration_generator.rb, line 17 def install_gems if options[:donttouchgem].blank? require_gems end end
Private Instance Methods
model()
click to toggle source
# File lib/generators/beautiful_migration_generator.rb, line 62 def model model_extracted = name.scan(/^Add(.*)To(.*)$/).flatten[1].underscore.singularize model_extracted = model_extracted.gsub("#{options[:mountable_engine].underscore}_",'') if !options[:mountable_engine].blank? return model_extracted end