Skip to content

Instantly share code, notes, and snippets.

@tigluiz
Created November 14, 2014 12:11
Show Gist options
  • Save tigluiz/e7af3f08e1c684b47837 to your computer and use it in GitHub Desktop.
Save tigluiz/e7af3f08e1c684b47837 to your computer and use it in GitHub Desktop.
Api
class API::BaseController < ActionController::Metal
include AbstractController::Callbacks
include AbstractController::Rendering
include ActionView::Layouts
include ActionController::ImplicitRender
include ActionController::Helpers
include ActionController::UrlFor
include ActionController::Head
include ActionController::Renderers::All
include ActionController::MimeResponds
include ActionController::Serialization
include ActionController::StrongParameters
include Devise::Controllers::Helpers
include Rails.application.routes.url_helpers
include ActionController::Rescue
end
class API::UsersController < API::BaseController
def create
user = User.new(user_params)
binding.pry
if user.save
render json: user, status: :created
else
render json: user.errors, status: :unprocessable_entity
end
end
private
def user_params
params.require(:user).permit(:first_name, :last_name, :password, :password_confirmation, :email)
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment