Class: Flexite::Config::UpdateService

Inherits:
ActionService show all
Defined in:
app/services/flexite/config/update_service.rb

Instance Method Summary collapse

Methods inherited from ActionService

#initialize

Constructor Details

This class inherits a constructor from Flexite::ActionService

Instance Method Details

#callObject



4
5
6
7
8
9
10
11
12
13
14
# File 'app/services/flexite/config/update_service.rb', line 4

def call
  if @form.invalid?
    return failure
  end

  @record = Config.joins("LEFT JOIN #{Entry.table_name} ON #{Entry.table_name}.parent_id = #{Config.table_name}.id AND #{Entry.table_name}.parent_type = '#{Config.model_name}'")
    .select("#{Config.table_name}.*, #{Entry.table_name}.id AS entry_id")
    .where(id: @form.id).first
  @record.update_attributes(@form.attributes)
  success
end