0

私は Formtastic を使用しており、現在のページを離れて /1/edit タイプの URL に移動することなく、編集アクションにアクセスするリモート フォームを設定しようとしています。

私のフォームは次のとおりです。

<%= semantic_form_for shipdr_website, :url => edit_shipdr_website_path(shipdr_website), :html => { :method => :post }, :remote => true do |f| %>
  <%= f.input :name, :input_html => { :value => shipdr_website.name } %>
  <%= f.input :url, :input_html => { :value => shipdr_website.url } %>
  <%= f.input :api_key, :input_html => { :value => shipdr_website.api_key }  %>
  <%= f.actions %>
<% end %>

ビューは shipdr/dash/websites の下にあります。ダッシュ ビューのコントローラーには編集アクションがないため、リモート フォームを使用して別のコントローラーの編集メソッドにアクセスする必要があります。

フォームが表示され、エラーが表示されずにページが読み込まれますが、[Web サイトの作成] ボタンをクリックしても何も起こりません。remote => true1 行目の部分を削除するNo route matches [POST] "/shipdr/websites/14/edit"と、ボタンをクリックしたときに表示されます。

レーキルートを使用した私のルートは次のとおりです。

 shipdr_dashboard_dashboard        /shipdr/dashboard/dashboard(.:format)       {:controller=>"shipdr/dashboard", :action=>"dashboard"}
            shipdr_websites GET    /shipdr/websites(.:format)                  {:action=>"index", :controller=>"shipdr/websites"}
                             POST   /shipdr/websites(.:format)                  {:action=>"create", :controller=>"shipdr/websites"}
         new_shipdr_website GET    /shipdr/websites/new(.:format)              {:action=>"new", :controller=>"shipdr/websites"}
        edit_shipdr_website GET    /shipdr/websites/:id/edit(.:format)         {:action=>"edit", :controller=>"shipdr/websites"}
             shipdr_website GET    /shipdr/websites/:id(.:format)              {:action=>"show", :controller=>"shipdr/websites"}
                             PUT    /shipdr/websites/:id(.:format)              {:action=>"update", :controller=>"shipdr/websites"}
                             DELETE /shipdr/websites/:id(.:format)              {:action=>"destroy", :controller=>"shipdr/websites"}
            shipdr_carriers GET    /shipdr/carriers(.:format)                  {:action=>"index", :controller=>"shipdr/carriers"}
                             POST   /shipdr/carriers(.:format)                  {:action=>"create", :controller=>"shipdr/carriers"}
         new_shipdr_carrier GET    /shipdr/carriers/new(.:format)              {:action=>"new", :controller=>"shipdr/carriers"}
        edit_shipdr_carrier GET    /shipdr/carriers/:id/edit(.:format)         {:action=>"edit", :controller=>"shipdr/carriers"}
             shipdr_carrier GET    /shipdr/carriers/:id(.:format)              {:action=>"show", :controller=>"shipdr/carriers"}
                             PUT    /shipdr/carriers/:id(.:format)              {:action=>"update", :controller=>"shipdr/carriers"}
                             DELETE /shipdr/carriers/:id(.:format)              {:action=>"destroy", :controller=>"shipdr/carriers"}
           shipdr_countries GET    /shipdr/countries(.:format)                 {:action=>"index", :controller=>"shipdr/countries"}
                             POST   /shipdr/countries(.:format)                 {:action=>"create", :controller=>"shipdr/countries"}
         new_shipdr_country GET    /shipdr/countries/new(.:format)             {:action=>"new", :controller=>"shipdr/countries"}
        edit_shipdr_country GET    /shipdr/countries/:id/edit(.:format)        {:action=>"edit", :controller=>"shipdr/countries"}
             shipdr_country GET    /shipdr/countries/:id(.:format)             {:action=>"show", :controller=>"shipdr/countries"}
                             PUT    /shipdr/countries/:id(.:format)             {:action=>"update", :controller=>"shipdr/countries"}
                             DELETE /shipdr/countries/:id(.:format)             {:action=>"destroy", :controller=>"shipdr/countries"}
     shipdr_shipping_groups GET    /shipdr/shipping_groups(.:format)           {:action=>"index", :controller=>"shipdr/shipping_groups"}
                             POST   /shipdr/shipping_groups(.:format)           {:action=>"create", :controller=>"shipdr/shipping_groups"}
  new_shipdr_shipping_group GET    /shipdr/shipping_groups/new(.:format)       {:action=>"new", :controller=>"shipdr/shipping_groups"}
 edit_shipdr_shipping_group GET    /shipdr/shipping_groups/:id/edit(.:format)  {:action=>"edit", :controller=>"shipdr/shipping_groups"}
      shipdr_shipping_group GET    /shipdr/shipping_groups/:id(.:format)       {:action=>"show", :controller=>"shipdr/shipping_groups"}
                             PUT    /shipdr/shipping_groups/:id(.:format)       {:action=>"update", :controller=>"shipdr/shipping_groups"}
                             DELETE /shipdr/shipping_groups/:id(.:format)       {:action=>"destroy", :controller=>"shipdr/shipping_groups"}
      shipdr_shipping_rules GET    /shipdr/shipping_rules(.:format)            {:action=>"index", :controller=>"shipdr/shipping_rules"}
                             POST   /shipdr/shipping_rules(.:format)            {:action=>"create", :controller=>"shipdr/shipping_rules"}
   new_shipdr_shipping_rule GET    /shipdr/shipping_rules/new(.:format)        {:action=>"new", :controller=>"shipdr/shipping_rules"}
  edit_shipdr_shipping_rule GET    /shipdr/shipping_rules/:id/edit(.:format)   {:action=>"edit", :controller=>"shipdr/shipping_rules"}
       shipdr_shipping_rule GET    /shipdr/shipping_rules/:id(.:format)        {:action=>"show", :controller=>"shipdr/shipping_rules"}
                             PUT    /shipdr/shipping_rules/:id(.:format)        {:action=>"update", :controller=>"shipdr/shipping_rules"}
                             DELETE /shipdr/shipping_rules/:id(.:format)        {:action=>"destroy", :controller=>"shipdr/shipping_rules"}
    shipdr_shipping_methods GET    /shipdr/shipping_methods(.:format)          {:action=>"index", :controller=>"shipdr/shipping_methods"}
                             POST   /shipdr/shipping_methods(.:format)          {:action=>"create", :controller=>"shipdr/shipping_methods"}
 new_shipdr_shipping_method GET    /shipdr/shipping_methods/new(.:format)      {:action=>"new", :controller=>"shipdr/shipping_methods"}
edit_shipdr_shipping_method GET    /shipdr/shipping_methods/:id/edit(.:format) {:action=>"edit", :controller=>"shipdr/shipping_methods"}
     shipdr_shipping_method GET    /shipdr/shipping_methods/:id(.:format)      {:action=>"show", :controller=>"shipdr/shipping_methods"}
                             PUT    /shipdr/shipping_methods/:id(.:format)      {:action=>"update", :controller=>"shipdr/shipping_methods"}
                             DELETE /shipdr/shipping_methods/:id(.:format)      {:action=>"destroy", :controller=>"shipdr/shipping_methods"}
        shipdr_ship_filters GET    /shipdr/ship_filters(.:format)              {:action=>"index", :controller=>"shipdr/ship_filters"}
                             POST   /shipdr/ship_filters(.:format)              {:action=>"create", :controller=>"shipdr/ship_filters"}
     new_shipdr_ship_filter GET    /shipdr/ship_filters/new(.:format)          {:action=>"new", :controller=>"shipdr/ship_filters"}
    edit_shipdr_ship_filter GET    /shipdr/ship_filters/:id/edit(.:format)     {:action=>"edit", :controller=>"shipdr/ship_filters"}
         shipdr_ship_filter GET    /shipdr/ship_filters/:id(.:format)          {:action=>"show", :controller=>"shipdr/ship_filters"}
                             PUT    /shipdr/ship_filters/:id(.:format)          {:action=>"update", :controller=>"shipdr/ship_filters"}
                             DELETE /shipdr/ship_filters/:id(.:format)          {:action=>"destroy", :controller=>"shipdr/ship_filters"}
               shipdr_zones GET    /shipdr/zones(.:format)                     {:action=>"index", :controller=>"shipdr/zones"}
                             POST   /shipdr/zones(.:format)                     {:action=>"create", :controller=>"shipdr/zones"}
            new_shipdr_zone GET    /shipdr/zones/new(.:format)                 {:action=>"new", :controller=>"shipdr/zones"}
           edit_shipdr_zone GET    /shipdr/zones/:id/edit(.:format)            {:action=>"edit", :controller=>"shipdr/zones"}
                shipdr_zone GET    /shipdr/zones/:id(.:format)                 {:action=>"show", :controller=>"shipdr/zones"}
                             PUT    /shipdr/zones/:id(.:format)                 {:action=>"update", :controller=>"shipdr/zones"}
                             DELETE /shipdr/zones/:id(.:format)                 {:action=>"destroy", :controller=>"shipdr/zones"}
      new_admin_user_session GET    /admin_users/sign_in(.:format)               {:action=>"new", :controller=>"devise/sessions"}
          admin_user_session POST   /admin_users/sign_in(.:format)               {:action=>"create", :controller=>"devise/sessions"}
  destroy_admin_user_session DELETE /admin_users/sign_out(.:format)              {:action=>"destroy", :controller=>"devise/sessions"}
         admin_user_password POST   /admin_users/password(.:format)              {:action=>"create", :controller=>"devise/passwords"}
     new_admin_user_password GET    /admin_users/password/new(.:format)          {:action=>"new", :controller=>"devise/passwords"}
    edit_admin_user_password GET    /admin_users/password/edit(.:format)         {:action=>"edit", :controller=>"devise/passwords"}
                             PUT    /admin_users/password(.:format)              {:action=>"update", :controller=>"devise/passwords"}
            new_user_session GET    /users/sign_in(.:format)                     {:action=>"new", :controller=>"devise/sessions"}
                user_session POST   /users/sign_in(.:format)                     {:action=>"create", :controller=>"devise/sessions"}
        destroy_user_session DELETE /users/sign_out(.:format)                    {:action=>"destroy", :controller=>"devise/sessions"}
      user_omniauth_callback        /users/auth/:action/callback(.:format)       {:action=>/google/, :controller=>"omniauth/omniauth_callbacks"}
               user_password POST   /users/password(.:format)                    {:action=>"create", :controller=>"devise/passwords"}
           new_user_password GET    /users/password/new(.:format)                {:action=>"new", :controller=>"devise/passwords"}
          edit_user_password GET    /users/password/edit(.:format)               {:action=>"edit", :controller=>"devise/passwords"}
                             PUT    /users/password(.:format)                    {:action=>"update", :controller=>"devise/passwords"}
    cancel_user_registration GET    /users/cancel(.:format)                      {:action=>"cancel", :controller=>"devise/registrations"}
           user_registration POST   /users(.:format)                             {:action=>"create", :controller=>"devise/registrations"}
       new_user_registration GET    /users/sign_up(.:format)                     {:action=>"new", :controller=>"devise/registrations"}
      edit_user_registration GET    /users/edit(.:format)                        {:action=>"edit", :controller=>"devise/registrations"}
                             PUT    /users(.:format)                             {:action=>"update", :controller=>"devise/registrations"}
                             DELETE /users(.:format)                             {:action=>"destroy", :controller=>"devise/registrations"}
                       users GET    /users(.:format)                             {:action=>"index", :controller=>"users"}
                             POST   /users(.:format)                             {:action=>"create", :controller=>"users"}
                    new_user GET    /users/new(.:format)                         {:action=>"new", :controller=>"users"}
                   edit_user GET    /users/:id/edit(.:format)                    {:action=>"edit", :controller=>"users"}
                        user GET    /users/:id(.:format)                         {:action=>"show", :controller=>"users"}
                             PUT    /users/:id(.:format)                         {:action=>"update", :controller=>"users"}
                             DELETE /users/:id(.:format)                         {:action=>"destroy", :controller=>"users"}
               pages_contact GET    /pages/contact(.:format)                     {:controller=>"pages", :action=>"contact"}
               pages_pricing GET    /pages/pricing(.:format)                     {:controller=>"pages", :action=>"pricing"}
              pages_features GET    /pages/features(.:format)                    {:controller=>"pages", :action=>"features"}
            pages_howitworks GET    /pages/howitworks(.:format)                  {:controller=>"pages", :action=>"howitworks"}
                  pages_home GET    /pages/home(.:format)                        {:controller=>"pages", :action=>"home"}
                    settings        /settings(.:format)                          {:controller=>"pages", :action=>"settings"}
                             GET    /shipdr/dashboard/dashboard(.:format)       {:controller=>"shipdr/dashboard", :action=>"dashboard"}
     shipdr_dashboard_rules GET    /shipdr/dashboard/rules(.:format)           {:controller=>"shipdr/dashboard", :action=>"rules"}
      shipdr_dashboard_ship GET    /shipdr/dashboard/ship(.:format)            {:controller=>"shipdr/dashboard", :action=>"ship"}
  shipdr_dashboard_validate GET    /shipdr/dashboard/validate(.:format)        {:controller=>"shipdr/dashboard", :action=>"validate"}
 shipdr_dashboard_analytics GET    /shipdr/dashboard/analytics(.:format)       {:controller=>"shipdr/dashboard", :action=>"analytics"}
  shipdr_dashboard_carriers GET    /shipdr/dashboard/carriers(.:format)        {:controller=>"shipdr/dashboard", :action=>"carriers"}
  shipdr_dashboard_websites GET    /shipdr/dashboard/websites(.:format)        {:controller=>"shipdr/dashboard", :action=>"websites"}
                        root        /                                            {:controller=>"pages", :action=>"home"}

これを理解するための助けをいただければ幸いです。

4

1 に答える 1

0

routes.rb ファイルを確認しましたか? レーキルート情報を教えてください

あなたのコントローラーは ajax リクエスト用にセットアップされていますか?

セマンティック形式に作用する必要な JavaScript はありますか?

これらは、フォームを機能させるために調べる必要があるものです。

https://gist.github.com/548387?file=tickets_controller.rbをチェックして、必要な情報を把握してください。

于 2012-06-01T14:56:00.753 に答える