Class: LesliGuard::DescriptorsController

Inherits:
ApplicationController show all
Defined in:
app/controllers/lesli_guard/descriptors_controller.rb

Instance Method Summary collapse

Instance Method Details

#createObject

POST /descriptors



77
78
79
80
81
82
83
84
85
86
# File 'app/controllers/lesli_guard/descriptors_controller.rb', line 77

def create
    descriptor = DescriptorService.new(current_user, query).create(descriptor_params)

    # Check if the creation went ok
    if descriptor.successful?
        respond_with_successful(descriptor)
    else
        respond_with_error(descriptor.errors)
    end
end

#destroyObject

DELETE /descriptors/1



103
104
105
106
107
108
109
110
111
112
113
114
# File 'app/controllers/lesli_guard/descriptors_controller.rb', line 103

def destroy
    return respond_with_not_found unless @descriptor.found?

    @descriptor.destroy

    # Check if the deletion went ok
    unless @descriptor.successful?
        return respond_with_error(@descriptor.errors)
    end

    respond_with_successful
end

#editObject

GET /descriptors/:id/edit



73
74
# File 'app/controllers/lesli_guard/descriptors_controller.rb', line 73

def edit
end

#indexObject

GET /descriptors



48
49
50
51
52
53
54
55
56
# File 'app/controllers/lesli_guard/descriptors_controller.rb', line 48

def index
    respond_to do |format|
        format.html {}
        format.json do
            #respond_with_successful(DescriptorService.new(current_user, query).index)
            respond_with_pagination(DescriptorService.new(current_user, query).index)
        end
    end
end

#listObject

GET /descriptors/list.json



38
39
40
41
42
43
44
45
# File 'app/controllers/lesli_guard/descriptors_controller.rb', line 38

def list
    respond_to do |format|
        format.html {}
        format.json do
            respond_with_successful(DescriptorService.new(current_user, query).list)
        end
    end
end

#newObject

GET /descriptors/new



69
70
# File 'app/controllers/lesli_guard/descriptors_controller.rb', line 69

def new
end

#showObject

GET /descriptors/:id



59
60
61
62
63
64
65
66
# File 'app/controllers/lesli_guard/descriptors_controller.rb', line 59

def show
    respond_to do |format|
        format.html {}
        format.json do
            respond_with_successful(@descriptor.show)
        end
    end
end

#updateObject

PATCH/PUT /descriptors/:id



89
90
91
92
93
94
95
96
97
98
99
100
# File 'app/controllers/lesli_guard/descriptors_controller.rb', line 89

def update
    return respond_with_not_found unless @descriptor.found?

    @descriptor.update(descriptor_params)

    # Check if the update went ok
    unless @descriptor.successful?
        return respond_with_error(@descriptor.errors)
    end

    respond_with_successful(@descriptor.result)
end