Class: Hai::RestController
- Inherits:
-
ApplicationController
- Object
- ApplicationController
- Hai::RestController
- Defined in:
- app/controllers/hai/rest_controller.rb
Instance Method Summary collapse
Instance Method Details
#create ⇒ Object
27 28 29 30 31 32 33 |
# File 'app/controllers/hai/rest_controller.rb', line 27 def create render json: Hai::Create .new(model_class, context) .execute(**params[params[:model].singularize].permit!) .to_json end |
#destroy ⇒ Object
46 47 48 49 50 51 52 |
# File 'app/controllers/hai/rest_controller.rb', line 46 def destroy render json: Hai::Delete .new(model_class, context) .execute(id: params[:id]) .to_json end |
#index ⇒ Object
4 5 6 7 8 9 10 11 12 13 14 15 16 17 |
# File 'app/controllers/hai/rest_controller.rb', line 4 def index render json: Hai::Read .new(model_class, context) .list( # TODO: this is a security risk, thanks co-pilot # potenntial use attributes types plus AREL_TYPE_CAST filter: params[:filter]&.to_unsafe_h, limit: params[:limit], offset: params[:offset], sort: params[:sort]&.to_unsafe_h ) .to_json end |