Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- class TicketingDashboard < ApplicationRecord
- belongs_to :user
- has_many :widgets, as: :widgetable
- belongs_to :reporting_application, optional: true
- after_create :create_all_widgets
- def create_all_widgets
- @new_widgets = []
- widgets ||= reporting_application.widget_blueprints.each do |wb|
- @new_widgets << {
- widget_blueprint_id: wb.id, name: wb.name, endpoint: wb.endpoint, query_url: nil, is_live: false, live_interval: 25, default_view: 'chart', slug_name: nil
- }
- end
- create_new_widgets
- end
- private
- def create_new_widgets
- widgets.create(@new_widgets)
- end
- end
Add Comment
Please, Sign In to add comment