当使用form_tag时,Rail的设计发出路由错误信号

时间:2013-11-18 15:37:14

标签: ruby ruby-on-rails-3 devise routes

有这个奇怪的问题,我甚至不知道如何标记它。

我收到此错误

没有路线匹配{:controller =>“devise / lite_sport_registration”,:action =>“init_by_token”}

当我尝试使用用户或组织者帐户(这是设计用途的两个模型)登录时输入“/ users / sign_in”

当我将此表单放在应用程序布局中时。

            <div id="registration" class="registration" style="text-align: center">
            <%= form_tag(:controller => 'lite_sport_registration', :action => 'init_by_token') do |f| %>
            Inscripciones&nbsp;
            <input type="text" value="" name="token" />
            <input type="submit" value="Iniciar Registro" />
            </br>
            <font style="text-align: center;font-style: italic">Escribe tu clave de registro express</font>&nbsp;&nbsp;&nbsp;<img src="/images/help.png" width="16px" style="vertical-align: middle" />
            <% end %>
        </div>

然而,当我为此更改它并硬编码没有标签的表单时,问题就消失了。

                <form method="POST" action="/registration/lite_sports/init">
            Inscripciones&nbsp;
            <input type="text" value="" name="token" />
            <input type="submit" value="Iniciar Registro" />
            </br>
            <font style="text-align: center;font-style: italic">Escribe tu clave de registro express</font>&nbsp;&nbsp;&nbsp;<img src="/images/help.png" width="16px" style="vertical-align: middle" />
            </font>
            </form>

lite_sport_registration控制器与设计完全无关,并且不知何故问题是由什么引起的。知道为什么吗?

这是我的路线表

              new_organizer_session GET    /organizers/sign_in(.:format)                                                   devise/sessions#new
               organizer_session POST   /organizers/sign_in(.:format)                                                   devise/sessions#create
       destroy_organizer_session DELETE /organizers/sign_out(.:format)                                                  devise/sessions#destroy
              organizer_password POST   /organizers/password(.:format)                                                  devise/passwords#create
          new_organizer_password GET    /organizers/password/new(.:format)                                              devise/passwords#new
         edit_organizer_password GET    /organizers/password/edit(.:format)                                             devise/passwords#edit
                                 PUT    /organizers/password(.:format)                                                  devise/passwords#update
   cancel_organizer_registration GET    /organizers/cancel(.:format)                                                    devise/registrations#cancel
          organizer_registration POST   /organizers(.:format)                                                           devise/registrations#create
      new_organizer_registration GET    /organizers/sign_up(.:format)                                                   devise/registrations#new
     edit_organizer_registration GET    /organizers/edit(.:format)                                                      devise/registrations#edit
                                 PUT    /organizers(.:format)                                                           devise/registrations#update
                                 DELETE /organizers(.:format)                                                           devise/registrations#destroy
                new_user_session GET    /users/sign_in(.:format)                                                        devise/sessions#new
                    user_session POST   /users/sign_in(.:format)                                                        devise/sessions#create
            destroy_user_session DELETE /users/sign_out(.:format)                                                       devise/sessions#destroy
                   user_password POST   /users/password(.:format)                                                       devise/passwords#create
               new_user_password GET    /users/password/new(.:format)                                                   devise/passwords#new
              edit_user_password GET    /users/password/edit(.:format)                                                  devise/passwords#edit
                                 PUT    /users/password(.:format)                                                       devise/passwords#update
        cancel_user_registration GET    /users/cancel(.:format)                                                         devise/registrations#cancel
               user_registration POST   /users(.:format)                                                                devise/registrations#create
           new_user_registration GET    /users/sign_up(.:format)                                                        devise/registrations#new
          edit_user_registration GET    /users/edit(.:format)                                                           devise/registrations#edit
                                 PUT    /users(.:format)                                                                devise/registrations#update
                                 DELETE /users(.:format)                                                                devise/registrations#destroy


       registration_lite_sports_init POST   /registration/lite_sports/init(.:format)                                        lite_sport_registration#init_by_token
                                 GET    /registration/lite_sports/:event_id/start(.:format)                             lite_sport_registration#start
                                 POST   /registration/lite_sports/:event_id/start(.:format)                             lite_sport_registration#start_do
                                 GET    /registration/lite_sports/:event_id/basedata(.:format)                          lite_sport_registration#base_data
                                 POST   /registration/lite_sports/:event_id/basedata(.:format)                          lite_sport_registration#base_data_do
                                 GET    /registration/lite_sports/:event_id/confirm(.:format)                           lite_sport_registration#confirm
                                 POST   /registration/lite_sports/:event_id/confirm(.:format)                           lite_sport_registration#confirm_do
                                 GET    /registration/lite_sports/:event_id/confirmation(.:format)                      lite_sport_registration#confirmation
                                 GET    /registration/lite_sports/:event_id/pdf_confirmation/:registration_id(.:format) lite_sport_registration#pdf_confirmation
                                 GET    /registration/lite_sports/:event_id/recover(.:format)                           lite_sport_registration#recover
                                 POST   /registration/lite_sports/:event_id/recover(.:format)                           lite_sport_registration#recover

registration_lite_sports_categories GET /registration/lite_sports/categories(.:format)lite_sport_registration#categories                                      GET /registration/lite_sports/:event_id/terms(.:format)lite_sport_registration# terms      registration_lite_sports_qrcode GET /registration/lite_sports/qrcode(.:format)lite_sport_registration#qrcode     registration_lite_sports_barcode GET /registration/lite_sports/barcode(.:format)lite_sport_registration#barcode

1 个答案:

答案 0 :(得分:0)

您在这里有一条命名路线,因此只需使用registration_lite_sports_init_path代替:controller => 'lite_sport_registration', :action => 'init_by_token'