Class: Meroku::ConfigsController
- Inherits:
-
ApplicationController
- Object
- ApplicationController
- Meroku::ConfigsController
- Defined in:
- lib/meroku/configs_controller.rb
Instance Method Summary collapse
- #create ⇒ Object
-
#destroy ⇒ Object
DELETE /keys/1 DELETE /keys/1.json.
- #index ⇒ Object
Instance Method Details
#create ⇒ Object
15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 |
# File 'lib/meroku/configs_controller.rb', line 15 def create @config = Meroku::Config.where(name: params["name"], app_id: @app_.id).try(:first) if @config # if variable exists, update its value @config.update_attributes(value: params["value"]) else # if it doesn't exist, create record @config = Meroku::Config.new( name: params["name"], value: params["value"], app_id: @app_.id ) end respond_to do |format| if @config.save format.json { render json: { data: @config } } else format.json { render json: { :errors => @config.errors }, status: :unprocessable_entity } end end end |