Module: RecordsControllerBehavior

Extended by:
ActiveSupport::Concern
Included in:
RecordsController
Defined in:
app/controllers/concerns/records_controller_behavior.rb

Defined Under Namespace

Modules: ClassMethods

Instance Method Summary collapse

Instance Method Details

#createObject



32
33
34
35
36
37
38
39
40
41
42
43
44
45
# File 'app/controllers/concerns/records_controller_behavior.rb', line 32

def create
  set_attributes

  respond_to do |format|
    if resource.save
      format.html { redirect_to redirect_after_create, notice: 'Object was successfully created.' }
      format.json { render json: object_as_json, status: :created, location: redirect_after_create }
    else
      format.html { render action: "new" }
      format.json { render json: resource.errors, status: :unprocessable_entity }
    end
  end

end

#editObject



27
28
29
30
# File 'app/controllers/concerns/records_controller_behavior.rb', line 27

def edit
  initialize_fields
  render 'records/edit'
end

#newObject



22
23
24
25
# File 'app/controllers/concerns/records_controller_behavior.rb', line 22

def new
  initialize_fields
  render 'records/new'
end

#updateObject



47
48
49
50
51
52
53
54
55
56
57
58
# File 'app/controllers/concerns/records_controller_behavior.rb', line 47

def update
  set_attributes
  respond_to do |format|
    if resource.save
      format.html { redirect_to redirect_after_update, notice: 'Object was successfully updated.' }
      format.json { head :no_content }
    else
      format.html { render action: "edit" }
      format.json { render json: resource.errors, status: :unprocessable_entity }
    end
  end
end