You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I would like to create a documentation file for RESTful Ruby on Rails application. This project helped me to retrieve the HTTP paths, verbs and also the parameters.
For getting the content type of responses and request, I tried with it and couldn't get any entry.
*I using Rails 4.1
My controller is as the following:
classAutosController < ApplicationControllerbefore_action:set_auto,only: [:show,:edit,:update,:destroy]# GET /autos# GET /autos.jsondefindex@autos=Auto.allend# GET /autos/1# GET /autos/1.jsondefshowend# GET /autos/newdefnew@auto=Auto.newend# GET /autos/1/editdefeditend# POST /autos# POST /autos.jsondefcreate@auto=Auto.new(auto_params)respond_todo |format|
if@auto.saveformat.html{redirect_to@auto,notice: 'Auto was successfully created.'}format.json{render:show,status: :created,location: @auto}elseformat.html{render:new}format.json{renderjson: @auto.errors,status: :unprocessable_entity}endendend# PATCH/PUT /autos/1# PATCH/PUT /autos/1.jsondefupdaterespond_todo |format|
if@auto.update(auto_params)format.html{redirect_to@auto,notice: 'Auto was successfully updated.'}format.json{render:show,status: :ok,location: @auto}elseformat.html{render:edit}format.json{renderjson: @auto.errors,status: :unprocessable_entity}endendend# DELETE /autos/1# DELETE /autos/1.jsondefdestroy@auto.destroyrespond_todo |format|
format.html{redirect_toautos_url,notice: 'Auto was successfully destroyed.'}format.json{head:no_content}endenddefbuy@auto=Auto.find(params[:id])respond_todo |format|
if@auto.update_attribute(:gekauft,true)format.html{redirect_to@auto,notice: 'Auto wurde erfolgreich gekauft.'}format.json{head:no_content}elseformat.html{redirect_to@auto,notice: 'Fehler beim Kauf.'}format.json{renderjson: @auto.errors,status: :unprocessable_entity}endendenddefsell@auto=Auto.find(params[:id])respond_todo |format|
if@auto.update_attribute(:gekauft,false)format.html{redirect_to@auto,notice: 'Auto wurde erfolgreich verkauft.'}format.json{head:no_content}elseformat.html{redirect_to@auto,notice: 'Fehler beim Verkauf.'}format.json{renderjson: @auto.errors,status: :unprocessable_entity}endendendprivate# Use callbacks to share common setup or constraints between actions.defset_auto@auto=Auto.find(params[:id])end# Never trust parameters from the scary internet, only allow the white list through.defauto_paramsparams.require(:auto).permit(:farbe,:anzahl_sitze,:gekauft)endend
The text was updated successfully, but these errors were encountered:
I agree - that would be a really cool feature to have! I don't really know how to extract that information in a dynamic typed language, though. Do you have any suggestions on how it could be done?
Hi Austvik,
Thanks for the tip. Well I tried to retrieve that from the responder attribute from the Controller object, but as beginner in Rails I don't know how.
I would like to create a documentation file for RESTful Ruby on Rails application. This project helped me to retrieve the HTTP paths, verbs and also the parameters.
For getting the content type of responses and request, I tried with it and couldn't get any entry.
*I using Rails 4.1
My controller is as the following:
The text was updated successfully, but these errors were encountered: