Last active
August 29, 2015 14:03
-
-
Save heridev/5733b5ea01995142f57b to your computer and use it in GitHub Desktop.
Problema con la api routes
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# si deseas utilizar el codigo que adjuntas que es el siguiente | |
class Api::ResponsesController < ApplicationController | |
respond_to :json | |
def index | |
json_response = { | |
models: "hola" | |
} | |
respond_with json_response | |
end | |
end | |
namespace :api do | |
resources :responses,format: :json | |
end | |
# la ruta a la cual tienes que acceder | |
# es la siguiente liga | |
http://localhost:3000/api/responses.json | |
# si por el contrario no quieres especificar la extension puedes utilizar | |
# format: 'json' o tambien puedes utilizar el siguiente codigo : | |
class Api::ResponsesController < ApplicationController | |
def index | |
json_response = { | |
models: "hola" | |
} | |
render json: json_response | |
end | |
end | |
namespace :api do | |
resources :responses,format: :json | |
end | |
## como te comento son tres opciones utilizando respond_with y | |
# especificar en tu ruta la extension .json o cambiar | |
# el format a format: 'json' o utilizar render json: sin el | |
# respond_with y el format: :json como simbolo | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
me quedo perfectamente claro José Heriberto, muchas gracias por tomarte el tiempo.