Class: Cadinsor::ApiKeysController

Inherits:
ApplicationController show all
Defined in:
app/controllers/cadinsor/api_keys_controller.rb

Instance Method Summary collapse

Instance Method Details

#createObject



6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
# File 'app/controllers/cadinsor/api_keys_controller.rb', line 6

def create
  @key = ApiKey.new
  @key.client_app_id = params[Cadinsor::Engine.config.api_key_param_name].to_i if params[Cadinsor::Engine.config.api_key_param_name]
  @key.generate_key!
  if @key.save
    respond_to do |format|
      format.json {redirect_to :action => 'show', :format => 'json', :key => @key.key}
      format.xml {redirect_to :action => 'show', :format => 'xml', :key => @key.key}
    end
  else
    respond_to do |format|
      format.json
      format.xml
    end
  end
end

#showObject



23
24
25
26
27
# File 'app/controllers/cadinsor/api_keys_controller.rb', line 23

def show
  if params[:key]
    @key = ApiKey.find_by_key(params[:key])
  end
end