Class: Tomify::Api::Public::UsersController
- Inherits:
-
Object
- Object
- Tomify::Api::Public::UsersController
- Defined in:
- app/controllers/tomify/api/public/users_controller.rb
Instance Method Summary collapse
Instance Method Details
#create ⇒ Object
6 7 8 9 10 11 |
# File 'app/controllers/tomify/api/public/users_controller.rb', line 6 def create session[:current_user_id] = Tomify.models.user.create!(record_params).id render json: { type: :success }, success: "Welcome #{current_user.name}!" rescue ActiveRecord::RecordInvalid => e render json: { type: :warning, message: e.record.errors..join(", ") } end |
#destroy ⇒ Object
20 21 22 23 24 25 |
# File 'app/controllers/tomify/api/public/users_controller.rb', line 20 def destroy flash[:danger] = "Goodbye #{current_user.name}" find_record destroy_record render json: { type: :success } end |
#update ⇒ Object
13 14 15 16 17 18 |
# File 'app/controllers/tomify/api/public/users_controller.rb', line 13 def update current_user.update!(record_params) render json: { type: :success, message: "Profile Updated" } rescue ActiveRecord::RecordInvalid => e render json: { type: :warning, message: e.record.errors..join(", ") } end |