Class: Optimizable::OptimizationsController
- Inherits:
-
Object
- Object
- Optimizable::OptimizationsController
- Defined in:
- app/controllers/optimizable/optimizations_controller.rb
Instance Method Summary collapse
-
#create ⇒ Object
POST /optimizations POST /optimizations.json.
-
#destroy ⇒ Object
DELETE /optimizations/1 DELETE /optimizations/1.json.
-
#edit ⇒ Object
GET /optimizations/1/edit.
-
#index ⇒ Object
GET /optimizations GET /optimizations.json.
-
#new ⇒ Object
GET /optimizations/new GET /optimizations/new.json.
-
#show ⇒ Object
GET /optimizations/1 GET /optimizations/1.json.
-
#update ⇒ Object
PUT /optimizations/1 PUT /optimizations/1.json.
Instance Method Details
#create ⇒ Object
POST /optimizations POST /optimizations.json
43 44 45 46 47 48 49 50 51 52 53 54 55 |
# File 'app/controllers/optimizable/optimizations_controller.rb', line 43 def create @optimization = Optimization.new(params[:optimizable_optimization]) respond_to do |format| if @optimization.save format.html { redirect_to optimization_path(@optimization), notice: 'Optimization was successfully created.' } format.json { render json: @optimization, status: :created, location: @optimization } else format.html { render action: "new" } format.json { render json: @optimization.errors, status: :unprocessable_entity } end end end |
#destroy ⇒ Object
DELETE /optimizations/1 DELETE /optimizations/1.json
75 76 77 78 79 80 81 82 83 |
# File 'app/controllers/optimizable/optimizations_controller.rb', line 75 def destroy @optimization = Optimization.find(params[:id]) @optimization.destroy respond_to do |format| format.html { redirect_to optimizations_url } format.json { head :ok } end end |
#edit ⇒ Object
GET /optimizations/1/edit
37 38 39 |
# File 'app/controllers/optimizable/optimizations_controller.rb', line 37 def edit @optimization = Optimization.find(params[:id]) end |
#index ⇒ Object
GET /optimizations GET /optimizations.json
5 6 7 8 9 10 11 12 |
# File 'app/controllers/optimizable/optimizations_controller.rb', line 5 def index @optimizations = Optimization.all respond_to do |format| format.html # index.html.erb format.json { render json: @optimizations } end end |
#new ⇒ Object
GET /optimizations/new GET /optimizations/new.json
27 28 29 30 31 32 33 34 |
# File 'app/controllers/optimizable/optimizations_controller.rb', line 27 def new @optimization = Optimization.new @optimization.optimizable = params[:optimizable_type].camelize.constantize.find(params[:optimizable_id]) respond_to do |format| format.html # new.html.erb format.json { render json: @optimization } end end |
#show ⇒ Object
GET /optimizations/1 GET /optimizations/1.json
16 17 18 19 20 21 22 23 |
# File 'app/controllers/optimizable/optimizations_controller.rb', line 16 def show @optimization = Optimization.find(params[:id]) respond_to do |format| format.html # show.html.erb format.json { render json: @optimization } end end |
#update ⇒ Object
PUT /optimizations/1 PUT /optimizations/1.json
59 60 61 62 63 64 65 66 67 68 69 70 71 |
# File 'app/controllers/optimizable/optimizations_controller.rb', line 59 def update @optimization = Optimization.find(params[:id]) respond_to do |format| if @optimization.update_attributes(params[:optimizable_optimization]) format.html { redirect_to optimization_path(@optimization), notice: 'Optimization was successfully updated.' } format.json { head :ok } else format.html { render action: "edit" } format.json { render json: @optimization.errors, status: :unprocessable_entity } end end end |