Class: LesliBabel::BucketsController

Inherits:
ApplicationController show all
Defined in:
app/controllers/lesli_babel/buckets_controller.rb

Instance Method Summary collapse

Instance Method Details

#createObject

POST /buckets



63
64
65
66
67
68
69
70
71
72
73
# File 'app/controllers/lesli_babel/buckets_controller.rb', line 63

def create
    bucket = Bucket.new(bucket_params)
    bucket.module = Module.find(params[:module_id])
    bucket.reference_module = bucket.module.name

    if bucket.save
        respond_with_successful bucket
    else
        respond_with_error bucket.errors.full_messages
    end
end

#destroyObject

DELETE /buckets/1



85
86
87
88
# File 'app/controllers/lesli_babel/buckets_controller.rb', line 85

def destroy
@bucket.destroy
redirect_to buckets_url, notice: 'Bucket was successfully destroyed.'
end

#editObject

GET /buckets/1/edit



59
60
# File 'app/controllers/lesli_babel/buckets_controller.rb', line 59

def edit
end

#indexObject

GET /buckets



38
39
40
41
42
43
44
45
46
47
# File 'app/controllers/lesli_babel/buckets_controller.rb', line 38

def index
    respond_to do |format|
        format.html { }
        format.json { 
            respond_with_successful(
                Module.find(params[:module_id]).buckets.order(:code)
            ) 
        }
    end
end

#newObject

GET /buckets/new



54
55
56
# File 'app/controllers/lesli_babel/buckets_controller.rb', line 54

def new
@bucket = Bucket.new
end

#showObject

GET /buckets/1



50
51
# File 'app/controllers/lesli_babel/buckets_controller.rb', line 50

def show
end

#updateObject

PATCH/PUT /buckets/1



76
77
78
79
80
81
82
# File 'app/controllers/lesli_babel/buckets_controller.rb', line 76

def update
if @bucket.update(bucket_params)
redirect_to @bucket, notice: 'Bucket was successfully updated.'
else
render :edit
end
end