module-and-template-store/app/controllers/api/v1/clients_controller.rb

25 lines
715 B
Ruby
Raw Normal View History

2014-02-13 06:51:23 +00:00
module Api
module V1
class ClientsController < Api::V1::BaseController
respond_to :json
def create
2014-02-19 07:16:58 +00:00
@client = Client.new(client_params)
if @client.save
2014-02-24 06:48:32 +00:00
@client.send_confirmation_email
2014-02-19 08:12:32 +00:00
render :json => { :success => true, :client => @client.to_json }
2014-02-19 07:16:58 +00:00
else
render :json => { :errors => @client.errors.full_messages , :status => 422}.to_json
end
2014-02-13 06:51:23 +00:00
end
2014-02-18 10:34:52 +00:00
2014-02-13 06:51:23 +00:00
private
# Never trust parameters from the scary internet, only allow the white list through.
def client_params
2014-02-18 09:06:53 +00:00
params.require(:client).permit(:site_name, :site_token, :site_id, :university, :department, :email, :country, :url)
2014-02-13 06:51:23 +00:00
end
end
end
end