Created
November 14, 2014 12:11
-
-
Save tigluiz/e7af3f08e1c684b47837 to your computer and use it in GitHub Desktop.
Api
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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