Sha256: 7a9bc0103bfcafe5277f8368ad3086d243ce8bca4a077f5103cd747e7ce25d4f

Contents?: true

Size: 979 Bytes

Versions: 1

Compression:

Stored size: 979 Bytes

Contents

require_dependency "cadenero/application_controller"

module Cadenero
  module V1
    class AccountsController < Cadenero::ApplicationController
      def new
        errors = %Q{Please sign up. posting the account json data as {account: { name: "Testy", subdomain: "test", owner_attributes: {email: "testy@example.com", password: "changeme", password_confirmation: "changeme"} }} to /v1/accounts/sign_up}
        render json: {errors: errors, links: "/v1/accounts/sign_up"}, status: 422
      end
      def create
        @account = Cadenero::V1::Account.create_with_owner(params[:account])
        if @account.valid?
          @account.create_schema
          @account.ensure_authentication_token!
          force_authentication!(@account.owner)
          render json: @account, status: :created
        else
          @data = {
            errors: @account.errors
          }
          render json: @data, status: :unprocessable_entity
        end
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
cadenero-0.0.2.a3 app/controllers/cadenero/v1/accounts_controller.rb