Module: VisualMigrate::ApplicationHelper
- Included in:
- VisualMigrate
- Defined in:
- app/helpers/visual_migrate/application_helper.rb
Instance Method Summary collapse
- #columns_select(column_id, table, select = nil) ⇒ Object
- #func_select(id, select = nil) ⇒ Object
- #method_select(id, select = nil) ⇒ Object
- #nl2br(str) ⇒ Object
- #show_class(migration_class) ⇒ Object
- #show_columns(columns) ⇒ Object
- #show_disabled_method(migration_method) ⇒ Object
- #show_func(migration_func) ⇒ Object
- #show_method(migration_method) ⇒ Object
- #tables_select(table_id, select = nil) ⇒ Object
- #tables_select_with_ajax(table_id, update_div, method_id, func_id, table_select = nil, column_select = nil) ⇒ Object
- #type_select(id, select = nil) ⇒ Object
Instance Method Details
#columns_select(column_id, table, select = nil) ⇒ Object
34 35 36 37 |
# File 'app/helpers/visual_migrate/application_helper.rb', line 34 def columns_select(column_id, table, select = nil) logger.debug Kernel.const_get(table.singularize.camelize).column_names.inspect + '-----' select_tag(column_id, (Kernel.const_get(table.singularize.camelize).column_names, select)) end |
#func_select(id, select = nil) ⇒ Object
11 12 13 |
# File 'app/helpers/visual_migrate/application_helper.rb', line 11 def func_select(id, select = nil) select_tag(id, (MigrationDefs::FuncName.keys, select), prompt: 'Select') end |
#method_select(id, select = nil) ⇒ Object
7 8 9 |
# File 'app/helpers/visual_migrate/application_helper.rb', line 7 def method_select(id, select = nil) select_tag(id, (MigrationDefs::MethodName, select)) end |
#nl2br(str) ⇒ Object
3 4 5 |
# File 'app/helpers/visual_migrate/application_helper.rb', line 3 def nl2br(str) str.gsub(/\r\n|\r|\n/, "<br />") end |
#show_class(migration_class) ⇒ Object
39 40 41 42 |
# File 'app/helpers/visual_migrate/application_helper.rb', line 39 def show_class(migration_class) @migration_class = migration_class render partial: "layouts/visual_migrate/migration_class"#Why??? end |
#show_columns(columns) ⇒ Object
87 88 89 90 |
# File 'app/helpers/visual_migrate/application_helper.rb', line 87 def show_columns(columns) @columns = columns render partial: "layouts/visual_migrate/columns" end |
#show_disabled_method(migration_method) ⇒ Object
50 51 52 53 54 |
# File 'app/helpers/visual_migrate/application_helper.rb', line 50 def show_disabled_method(migration_method) @migration_method = migration_method @enable = false render partial: "layouts/visual_migrate/migration_method" end |
#show_func(migration_func) ⇒ Object
56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 |
# File 'app/helpers/visual_migrate/application_helper.rb', line 56 def show_func(migration_func) @migration_func = migration_func if @migration_func.instance_of? MigrationDefs::CreateTableFunc render partial: "layouts/visual_migrate/func_create_table" elsif @migration_func.instance_of? MigrationDefs::RenameTableFunc render partial: "layouts/visual_migrate/func_rename_table" elsif @migration_func.instance_of? MigrationDefs::DropTableFunc render partial: "layouts/visual_migrate/func_drop_table" elsif @migration_func.instance_of? MigrationDefs::AddColumnFunc render partial: "layouts/visual_migrate/func_add_column" elsif @migration_func.instance_of? MigrationDefs::RemoveColumnFunc render partial: "layouts/visual_migrate/func_remove_column" elsif @migration_func.instance_of? MigrationDefs::RenameColumnFunc render partial: "layouts/visual_migrate/func_rename_column" elsif @migration_func.instance_of? MigrationDefs::ChangeColumnFunc render partial: "layouts/visual_migrate/func_change_column" elsif @migration_func.instance_of? MigrationDefs::ChangeColumnDefaultFunc render partial: "layouts/visual_migrate/func_change_column_default" elsif @migration_func.instance_of? MigrationDefs::AddIndexFunc render partial: "layouts/visual_migrate/func_add_index" elsif @migration_func.instance_of? MigrationDefs::RemoveIndexFunc render partial: "layouts/visual_migrate/func_remove_index" elsif @migration_func.instance_of? MigrationDefs::RenameIndexFunc render partial: "layouts/visual_migrate/func_rename_index" elsif @migration_func.instance_of? MigrationDefs::AddTimestampsFunc render partial: "layouts/visual_migrate/func_add_timestamps" elsif @migration_func.instance_of? MigrationDefs::RemoveTimestampsFunc render partial: "layouts/visual_migrate/func_remove_timestamps" end end |
#show_method(migration_method) ⇒ Object
44 45 46 47 48 |
# File 'app/helpers/visual_migrate/application_helper.rb', line 44 def show_method(migration_method) @migration_method = migration_method @enable = true render partial: "layouts/visual_migrate/migration_method" end |
#tables_select(table_id, select = nil) ⇒ Object
15 16 17 |
# File 'app/helpers/visual_migrate/application_helper.rb', line 15 def tables_select(table_id, select = nil) select_tag(table_id, (ActiveRecord::Base.connection.tables, select), prompt: 'Select or input') end |
#tables_select_with_ajax(table_id, update_div, method_id, func_id, table_select = nil, column_select = nil) ⇒ Object
19 20 21 22 23 24 25 26 27 28 29 30 31 32 |
# File 'app/helpers/visual_migrate/application_helper.rb', line 19 def tables_select_with_ajax(table_id, update_div, method_id, func_id, table_select = nil, column_select = nil) select_tag(table_id, (ActiveRecord::Base.connection.tables, table_select), prompt: 'Select table', =begin data : { remote : true, url : url_for(action: :show_select_columns, id: column_id), type : "GET", dataType : 'html', data : {table_name: table_id, column_select: column_select}, update : update_div, }) =end onchange: "updateColumnsDiv(this.value, " + update_div + ", '" + method_id + "', '" + func_id + "');") end |
#type_select(id, select = nil) ⇒ Object
92 93 94 |
# File 'app/helpers/visual_migrate/application_helper.rb', line 92 def type_select(id, select = nil) select_tag(id, (MigrationDefs::ColumnType.keys, select)) end |