Class: DatatableState::StoreController

Inherits:
ApplicationController show all
Defined in:
app/controllers/datatable_state/store_controller.rb

Instance Method Summary collapse

Instance Method Details

#loadObject



25
26
27
28
29
30
31
32
# File 'app/controllers/datatable_state/store_controller.rb', line 25

def load
  result = if @store
    @store.state
  else
    {}.as_json
  end
  respond_with result
end

#saveObject



8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
# File 'app/controllers/datatable_state/store_controller.rb', line 8

def save
  if @store
    @store.update_attributes(store_params)
  else
    @store = Store.new(store_params)
    @store.user = current_user
  end

  respond_to do |format|
    if @store.save
      format.json { render json: @store, status: :created }
    else
      format.json { render json: @store.errors, status: :unprocessable_entity }
    end
  end
end