Sha256: fa8b96b8cfab9e971eea9a8c39ddf565817f429083f666bcc96ca0020b26f772
Contents?: true
Size: 1.22 KB
Versions: 1
Compression:
Stored size: 1.22 KB
Contents
class <%= controller_class_name %>Controller < ApiController before_action :rewrite_payload, only: :create load_and_authorize_resource def index render json: @<%= controller_class_name.underscore %>.collect(&:list_item_as_json) end def show render json: @<%= controller_class_name.singularize.underscore %>.display_as_json end def create if @<%= controller_class_name.singularize.underscore %>.save render json: { binary_urls: binary_urls(@<%= controller_class_name.singularize.underscore %>), response: @<%= controller_class_name.singularize.underscore %> }, status: :created else head :unprocessable_entity end end private def rewrite_payload Rails.logger.debug "Pre-rewrite params: #{params}" # Use this method to make any changes to parameters # Example to get properties from question # params[:payload][:name] = params.dig(:payload, :name, :answer) # Example to get properties from previous list # passport_id = params.dig(:payload, :choose_passport, :selected, :id) end def <%= controller_class_name.singularize.underscore %>_params # Permit any fields you want to save params.require(:payload).permit(:name) end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
mobile_workflow_cli-0.1.4 | templates/controller.rb |