Class: HomeController
- Inherits:
-
ApplicationController
- Object
- ApplicationController
- HomeController
- Defined in:
- lib/generators/connector/templates/home_controller.rb
Instance Method Summary collapse
-
#redirect_to_external ⇒ Object
Implement the redirection to the external application.
- #synchronize ⇒ Object
- #update ⇒ Object
Instance Method Details
#redirect_to_external ⇒ Object
Implement the redirection to the external application
33 34 35 |
# File 'lib/generators/connector/templates/home_controller.rb', line 33 def redirect_to_external redirect_to 'https://your_application.com' end |
#synchronize ⇒ Object
25 26 27 28 29 30 |
# File 'lib/generators/connector/templates/home_controller.rb', line 25 def synchronize return redirect_to(:back) unless is_admin Maestrano::Connector::Rails::SynchronizationJob.perform_later(current_organization.id, (params['opts'] || {}).merge(forced: true)) flash[:info] = 'Synchronization requested' redirect_to(:back) end |
#update ⇒ Object
3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 |
# File 'lib/generators/connector/templates/home_controller.rb', line 3 def update return redirect_to(:back) unless is_admin # Update list of entities to synchronize current_organization.synchronized_entities.keys.each do |entity| current_organization.synchronized_entities[entity][:can_push_to_connec] = params[entity.to_s]["to_connec"] == "1" current_organization.synchronized_entities[entity][:can_push_to_external] = params[entity.to_s]["to_external"] == "1" end full_sync = params['historical-data'].present? && !current_organization.historical_data opts = {full_sync: full_sync} current_organization.sync_enabled = current_organization.synchronized_entities.values.any? { |settings| settings.values.any? { |v| v } } current_organization.enable_historical_data(params['historical-data'].present?) trigger_sync = current_organization.sync_enabled current_organization.save # Trigger sync only if the sync has been enabled start_synchronization(opts) if trigger_sync redirect_to(:back) end |