Class: Localtower::PagesController
- Inherits:
-
ApplicationController
- Object
- ActionController::Base
- ApplicationController
- Localtower::PagesController
- Defined in:
- app/controllers/localtower/pages_controller.rb
Instance Method Summary collapse
- #migrations ⇒ Object
- #models ⇒ Object
- #new_migration ⇒ Object
- #new_model ⇒ Object
- #post_actions ⇒ Object
- #post_migrations ⇒ Object
- #post_models ⇒ Object
Methods inherited from ApplicationController
Instance Method Details
#migrations ⇒ Object
9 10 11 |
# File 'app/controllers/localtower/pages_controller.rb', line 9 def migrations @migrations = ::Localtower::Status.new.run end |
#models ⇒ Object
37 38 39 |
# File 'app/controllers/localtower/pages_controller.rb', line 37 def models @models = ::Localtower::Tools.models_presented end |
#new_migration ⇒ Object
5 6 7 |
# File 'app/controllers/localtower/pages_controller.rb', line 5 def new_migration @models = ::Localtower::Tools.models_presented end |
#new_model ⇒ Object
34 35 |
# File 'app/controllers/localtower/pages_controller.rb', line 34 def new_model end |
#post_actions ⇒ Object
59 60 61 62 63 |
# File 'app/controllers/localtower/pages_controller.rb', line 59 def post_actions cmd = ::Localtower::Tools.perform_cmd(clean_params['cmd']) flash[:notice] = cmd if cmd['ERROR'] redirect_back fallback_location: root_path end |
#post_migrations ⇒ Object
13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 |
# File 'app/controllers/localtower/pages_controller.rb', line 13 def post_migrations # Because we have a list or a field, take the item from the list in priority migrations = clean_params["migrations"].map do |action_line| # This is used for "rename_column" action: action_line["new_column_type"] = action_line["column_type"] if action_line["column_list"].present? action_line["column"] = action_line["column_list"] end action_line.delete("column_list") # / This is used for "rename_column" action action_line end use_generator(::Localtower::Generators::Migration, migrations) redirect_to migrations_path end |
#post_models ⇒ Object
41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 |
# File 'app/controllers/localtower/pages_controller.rb', line 41 def post_models model = clean_params["model"] model['attributes'] = model['attributes'].map do |attribute_line| # Convert checkbox to ruby value: attribute_line['nullable'] = false if attribute_line['nullable'].blank? # Convert index hash: if attribute_line['index'] attribute_line['index']['unique'] = true if attribute_line['index']['unique'] == 'true' end attribute_line end use_generator(::Localtower::Generators::Model, model) redirect_to migrations_path end |