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 12 |
# File 'app/controllers/tomify/api/public/users_controller.rb', line 6 def create session[:current_user_id] = Tomify.models.user.create!(record_params).id current_user.activities.create(action: action_name, controller: controller_name) 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
22 23 24 25 26 27 28 |
# File 'app/controllers/tomify/api/public/users_controller.rb', line 22 def destroy flash[:danger] = "Goodbye #{current_user.name}" current_user.activities.create(action: action_name, controller: controller_name) find_record destroy_record render json: { type: :success } end |
#update ⇒ Object
14 15 16 17 18 19 20 |
# File 'app/controllers/tomify/api/public/users_controller.rb', line 14 def update current_user.update!(record_params) current_user.activities.create(action: action_name, controller: controller_name) render json: { type: :success, message: "Profile Updated" } rescue ActiveRecord::RecordInvalid => e render json: { type: :warning, message: e.record.errors..join(", ") } end |