Class: RestEngine::MainController
- Inherits:
-
ApplicationController
- Object
- ApplicationController
- ApplicationController
- RestEngine::MainController
- Defined in:
- app/controllers/rest_engine/main_controller.rb
Instance Method Summary collapse
Instance Method Details
#create ⇒ Object
30 31 32 33 |
# File 'app/controllers/rest_engine/main_controller.rb', line 30 def create @item = @model.new(request.POST) @success = !!@item.save end |
#destroy ⇒ Object
25 26 27 28 |
# File 'app/controllers/rest_engine/main_controller.rb', line 25 def destroy @item = @model.find(params[:id]) @success = !!@item.destroy end |
#list ⇒ Object
7 8 9 10 11 12 13 14 15 16 17 18 19 |
# File 'app/controllers/rest_engine/main_controller.rb', line 7 def list = {} if params[:page] page = params[:page].to_i page = 1 if page <= 0 [:limit] = params[:limit].to_i [:offset] = (page - 1) * [:limit] end [:include] = @associations if @associations @items = @model.all() end |
#show ⇒ Object
21 22 23 |
# File 'app/controllers/rest_engine/main_controller.rb', line 21 def show @item = @model.find(params[:id]) end |
#update ⇒ Object
35 36 37 38 |
# File 'app/controllers/rest_engine/main_controller.rb', line 35 def update @item = @model.find(params[:id]) @success = !!@item.update_attributes(request.POST) end |