Module: Xavius::Controllers::Base

Extended by:
ActiveSupport::Concern
Defined in:
lib/xavius/controllers/base.rb

Instance Method Summary collapse

Instance Method Details

#createObject



17
18
19
20
21
22
23
24
25
26
27
# File 'lib/xavius/controllers/base.rb', line 17

def create
  respond_to do |format|
    if perform_action
      format.html { redirect_to action_context.resource, notice: success_message }
      format.json { render :show, status: :created, location: action_context.resource }
    else
      format.html { render :new, status: :unprocessable_entity }
      format.json { render json: action_context.resource.errors, status: :unprocessable_entity }
    end
  end
end

#destroyObject



41
42
43
44
45
46
47
# File 'lib/xavius/controllers/base.rb', line 41

def destroy
  perform_action
  respond_to do |format|
    format.html { redirect_to url_for(resource_class), notice: success_message }
    format.json { head :no_content }
  end
end

#indexObject



13
14
15
# File 'lib/xavius/controllers/base.rb', line 13

def index
  instance_variable_set(instance_variable_name_for(collection_name), perform_action)
end

#updateObject



29
30
31
32
33
34
35
36
37
38
39
# File 'lib/xavius/controllers/base.rb', line 29

def update
  respond_to do |format|
    if perform_action
      format.html { redirect_to action_context.resource, notice: success_message }
      format.json { render :show, status: :ok, location: action_context.resource }
    else
      format.html { render :edit, status: :unprocessable_entity }
      format.json { render json: action_context.resource.errors, status: :unprocessable_entity }
    end
  end
end