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
- #new_migration ⇒ Object
- #new_model ⇒ Object
- #post_actions ⇒ Object
- #post_migrations ⇒ Object
- #post_models ⇒ Object
- #rm_file ⇒ Object
Methods inherited from ApplicationController
Instance Method Details
#migrations ⇒ Object
10 11 12 |
# File 'app/controllers/localtower/pages_controller.rb', line 10 def migrations @migrations = ::Localtower::Status.new.run.take(30) end |
#new_migration ⇒ Object
5 6 7 8 |
# File 'app/controllers/localtower/pages_controller.rb', line 5 def new_migration @migrations = ::Localtower::Status.new.run.select { |i| i["status"] == :todo } @models = ::Localtower::Tools.models_presented end |
#new_model ⇒ Object
22 |
# File 'app/controllers/localtower/pages_controller.rb', line 22 def new_model; end |
#post_actions ⇒ Object
47 48 49 50 51 52 |
# File 'app/controllers/localtower/pages_controller.rb', line 47 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
14 15 16 17 18 19 20 |
# File 'app/controllers/localtower/pages_controller.rb', line 14 def post_migrations migrations = JSON.parse(clean_params['migrations']) ::Localtower::Generators::Migration.new(migrations, clean_params['migration_name']).run redirect_to new_migration_path end |
#post_models ⇒ Object
24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 |
# File 'app/controllers/localtower/pages_controller.rb', line 24 def post_models model = clean_params["model"] model['attributes'] = JSON.parse(model['attributes']).map do |attribute_line| # Convert checkbox to ruby value: attribute_line['nullable'] = false if attribute_line['nullable'].blank? attribute_line['index'] = nil if attribute_line['index'].blank? attribute_line end if model['attributes'].all? { |i| i['column_name'].present? } ::Localtower::Generators::Model.new(model).run redirect_to migrations_path else redirect_back fallback_location: root_path end end |
#rm_file ⇒ Object
42 43 44 45 |
# File 'app/controllers/localtower/pages_controller.rb', line 42 def rm_file File.delete(clean_params['file']) if File.exist?(clean_params['file']) redirect_back fallback_location: migrations_path end |