0

Started GET "/turnos/mostrar_turnos?provider=9920&date=2020-01-20" for ::1 at 2020-01-22 14:28:27 -0300
User excluded error: #<AbstractController::ActionNotFound: The action 'show' could not be found for TurnosController>
  
AbstractController::ActionNotFound (The action 'show' could not be found for TurnosController):
  
actionpack (5.2.3) lib/abstract_controller/base.rb:129:in `process'
actionview (5.2.3) lib/action_view/rendering.rb:32:in `process'
actionpack (5.2.3) lib/action_controller/metal.rb:191:in `dispatch'
actionpack (5.2.3) lib/action_controller/metal.rb:252:in `dispatch'
actionpack (5.2.3) lib/action_dispatch/routing/route_set.rb:52:in `dispatch'
actionpack (5.2.3) lib/action_dispatch/routing/route_set.rb:34:in `serve'
actionpack (5.2.3) lib/action_dispatch/journey/router.rb:52:in `block in serve'
actionpack (5.2.3) lib/action_dispatch/journey/router.rb:35:in `each'
actionpack (5.2.3) lib/action_dispatch/journey/router.rb:35:in `serve'
actionpack (5.2.3) lib/action_dispatch/routing/route_set.rb:840:in `call'
warden-jwt_auth (0.4.0) lib/warden/jwt_auth/middleware/token_dispatcher.rb:20:in `call'
warden-jwt_auth (0.4.0) lib/warden/jwt_auth/middleware/revocation_manager.rb:21:in `call'
rack (2.0.7) lib/rack/builder.rb:153:in `call'
warden-jwt_auth (0.4.0) lib/warden/jwt_auth/middleware.rb:23:in `call'
warden (1.2.8) lib/warden/manager.rb:36:in `block in call'
warden (1.2.8) lib/warden/manager.rb:34:in `catch'
warden (1.2.8) lib/warden/manager.rb:34:in `call'
rack (2.0.7) lib/rack/tempfile_reaper.rb:15:in `call'
rack (2.0.7) lib/rack/etag.rb:25:in `call'
rack (2.0.7) lib/rack/conditional_get.rb:25:in `call'
rack (2.0.7) lib/rack/head.rb:12:in `call'
actionpack (5.2.3) lib/action_dispatch/http/content_security_policy.rb:18:in `call'
rack (2.0.7) lib/rack/session/abstract/id.rb:232:in `context'
rack (2.0.7) lib/rack/session/abstract/id.rb:226:in `call'
actionpack (5.2.3) lib/action_dispatch/middleware/cookies.rb:670:in `call'
activerecord (5.2.3) lib/active_record/migration.rb:559:in `call'
actionpack (5.2.3) lib/action_dispatch/middleware/callbacks.rb:28:in `block in call'
activesupport (5.2.3) lib/active_support/callbacks.rb:98:in `run_callbacks'
actionpack (5.2.3) lib/action_dispatch/middleware/callbacks.rb:26:in `call'
actionpack (5.2.3) lib/action_dispatch/middleware/executor.rb:14:in `call'
actionpack (5.2.3) lib/action_dispatch/middleware/debug_exceptions.rb:61:in `call'
web-console (3.7.0) lib/web_console/middleware.rb:135:in `call_app'
web-console (3.7.0) lib/web_console/middleware.rb:30:in `block in call'
web-console (3.7.0) lib/web_console/middleware.rb:20:in `catch'
web-console (3.7.0) lib/web_console/middleware.rb:20:in `call'
actionpack (5.2.3) lib/action_dispatch/middleware/show_exceptions.rb:33:in `call'
railties (5.2.3) lib/rails/rack/logger.rb:38:in `call_app'
railties (5.2.3) lib/rails/rack/logger.rb:26:in `block in call'
activesupport (5.2.3) lib/active_support/tagged_logging.rb:71:in `block in tagged'
activesupport (5.2.3) lib/active_support/tagged_logging.rb:28:in `tagged'
activesupport (5.2.3) lib/active_support/tagged_logging.rb:71:in `tagged'
railties (5.2.3) lib/rails/rack/logger.rb:26:in `call'
sprockets-rails (3.2.1) lib/sprockets/rails/quiet_assets.rb:13:in `call'
actionpack (5.2.3) lib/action_dispatch/middleware/remote_ip.rb:81:in `call'
actionpack (5.2.3) lib/action_dispatch/middleware/request_id.rb:27:in `call'
rack (2.0.7) lib/rack/method_override.rb:22:in `call'
rack (2.0.7) lib/rack/runtime.rb:22:in `call'
activesupport (5.2.3) lib/active_support/cache/strategy/local_cache_middleware.rb:29:in `call'
actionpack (5.2.3) lib/action_dispatch/middleware/executor.rb:14:in `call'
actionpack (5.2.3) lib/action_dispatch/middleware/static.rb:127:in `call'
rack (2.0.7) lib/rack/sendfile.rb:111:in `call'
sentry-raven (2.11.0) lib/raven/integrations/rack.rb:51:in `call'
rack-cors (1.0.3) lib/rack/cors.rb:95:in `call'
railties (5.2.3) lib/rails/engine.rb:524:in `call'
puma (3.12.1) lib/puma/configuration.rb:227:in `call'
puma (3.12.1) lib/puma/server.rb:660:in `handle_request'
puma (3.12.1) lib/puma/server.rb:474:in `process_client'
puma (3.12.1) lib/puma/server.rb:334:in `block in run'
puma (3.12.1) lib/puma/thread_pool.rb:135:in `block in spawn_thread'

Tengo los siguientes archivos:

turnos_controller.rb

class TurnosController < ApplicationController
  def mostrar_turnos 
    @prov = params[:provider]
    @fecha = params[:date]

    @turnos_prestador1 = FirebirdDBModel.connection.execute("SELECT * from CONSULTORIOS_TURNOS('#{@prov}', '#{@fecha}') WHERE ID_TURNO IS NULL")
  end
end

index.html.erb

<form method="get" action="<%= mostrar_turnos_url %>">
  <p>Prestador:</p>
  <%= select_tag "provider", options_from_collection_for_select(Provider.order(:id), :id, :id ) %>
  <br>
  <input name="date" id="date" type="date" value="today()">
  <br>
  <input type="submit" value="Enviar">
</form>

mostrar_turnos.html.erb

<% if @turnos_prestador1.present?  %>
  <% @turnos_prestador1.each do |turnos_prestador1| %>
    <tr>
      <td> 
        <%= link_to turnos_prestador1[4].strftime("%I:%M"), turnos_path, data: { confirm: "El turno seleccionado es para el dia: '#{@fecha}' a las: '#{turnos_prestador1[4].strftime("%I:%M")}'. Desea confirmar?" }  %>
      </td>
    </tr>
  <% end %> 
<% else %>
  <p>No hay turnos disponibles para la fecha seleccionada.</p>
<% end %>

<br>
<%= link_to "Volver" ,turnos_path %>

Desde mi index.html.erb quiero llamar al metodo mostrar_turnos de mi controlador turnos y que me los muestre en mi archivo mostrar_turnos.html.erb. Lo que creo es que me esta direccionando a mi show que en realidad no existe. Ya que me dice en el error:

The action 'show' could not be found for TurnosController

Mi archivo routes.rb tiene la siguiente linea:

resources :turnos
get 'turnos/mostrar_turnos', as: 'mostrar_turnos'

Rails routes:

turnos_path GET /turnos(.:format)   
turnos#index

POST    /turnos(.:format)   
turnos#create

new_turno_path  GET /turnos/new(.:format)   
turnos#new

edit_turno_path GET /turnos/:id/edit(.:format)  
turnos#edit

turno_path  GET /turnos/:id(.:format)   
turnos#show

PATCH   /turnos/:id(.:format)   
turnos#update

 PUT    /turnos/:id(.:format)   
turnos#update

DELETE  /turnos/:id(.:format)   
turnos#destroy

 mostrar_turnos_path    GET /turnos/mostrar_turnos(.:format)    
 turnos#mostrar_turnos
14
  • ¿Puedes incluir el resultado del comando rails routes?
    – Gerry
    Commented el 22 ene. 2020 a las 15:46
  • Ahí lo edite y le agregue parte de las routes que me arroja el comando Commented el 22 ene. 2020 a las 16:56
  • Hmm, no veo razón para que te muestre el error; ¿podrías incluir el log que genera al realizar la petición al servidor (i.e. cuando das clic a Enviar)?
    – Gerry
    Commented el 22 ene. 2020 a las 17:10
  • También verifica el HTML generado en index.html (desde tu navegador: view source o similar).
    – Gerry
    Commented el 22 ene. 2020 a las 17:11
  • 1
    En efecto la solicitud está siendo direccionada antes de llegar a la acción, no sé exactamente dónde, pero yo buscaría en tu configuración de Warden, probablemente tengas una restricción que está ocasionando el redireccionamiento. ¿Cómo tienes configurado Warden?
    – Gerry
    Commented el 22 ene. 2020 a las 17:47

0

Tu Respuesta

By clicking “Publica tu respuesta”, you agree to our terms of service and acknowledge you have read our privacy policy.

Examina otras preguntas con la etiqueta o formula tu propia pregunta.