1

これは本当にイライラします。AA は私にとって非常にうまく機能していました。ほとんどすべてを試したと思います。これが私の問題です:

localhost ではすべて正常に動作しますが、Heroku にアクセスすると、奇妙なことが起こります。

マイ ダッシュボードには[Badge][Student]があります。

ですべてのバッジを表示できます/admin/badges。ただし、編集/表示/表示を実行すると、Heroku では問題が発生しますが、localhost では問題なく動作します。

検査すると、次のことが起こります。

ActionView::Template::Error (No route matches {:action=>"edit", :controller=>"admin/students", :id=>#<Student id: nil, email: "", encrypted_password: "", password_salt: "", reset_password_token: nil, remember_token: nil, remember_created_at: nil, sign_in_count: 0, current_sign_in_at: nil, last_sign_in_at: nil, current_sign_in_ip: nil, last_sign_in_ip: nil, avatar_file_name: nil, avatar_content_type: nil, avatar_file_size: nil, name: nil, role: nil, school: nil, parent_tutor_email: nil, parent_tutor_token: nil, pending_badge: nil, proficiency: 0.0, created_at: nil, account_type: "free", chargify_id: nil, fb_id: nil, score: 0, level_id: nil, special_bonuses: nil, birthday: nil, edu_level: nil>}):

1: render renderer_for(:show)

これ:idは Badge ID であると思われますが、空である Student オブジェクトによって上書きされます。

これが私のroute.rbファイルです:

WitsApp::Application.routes.draw do

  ActiveAdmin.routes(self)    
  devise_for :admin_users, ActiveAdmin::Devise.config


  devise_for :students, :controllers => {:registrations => "registrations", :sessions => "students_sessions", :passwords =>"devise/passwords"} do
    match 'students/sign_up'              => 'registrations#create',      :as => "student_sign_up"
    get   'students/sign_out'             => 'students_sessions#destroy'
    get   'students/sign_in'              => 'pages#welcome'
    get   'students/password/new'         => 'devise/passwords#new' 
    get   'students/password/edit'        => 'devise/passwords#edit' 
    post  'students/password'             => 'devise/passwords#create'
    put   'students/password'             => 'devise/passwords#update'

    get   'students', :to => 'students#show', :as => :student_root
    resources :badges
    resources :students
  end

  match '/sign_up' => 'pages#welcome', :as => "sign_up"

  root :to => "pages#home"
end

それが役立つ場合、ここにレーキルート(切り捨てられた)があります:

admin_dashboard        /admin(.:format)                                       {:action=>"index", :controller=>"admin/dashboard"}
         admin_comments GET    /admin/comments(.:format)                              {:action=>"index", :controller=>"admin/comments"}
                        POST   /admin/comments(.:format)                              {:action=>"create", :controller=>"admin/comments"}
      new_admin_comment GET    /admin/comments/new(.:format)                          {:action=>"new", :controller=>"admin/comments"}
     edit_admin_comment GET    /admin/comments/:id/edit(.:format)                     {:action=>"edit", :controller=>"admin/comments"}
          admin_comment GET    /admin/comments/:id(.:format)                          {:action=>"show", :controller=>"admin/comments"}
                        PUT    /admin/comments/:id(.:format)                          {:action=>"update", :controller=>"admin/comments"}
                        DELETE /admin/comments/:id(.:format)                          {:action=>"destroy", :controller=>"admin/comments"}
           admin_topics GET    /admin/topics(.:format)                                {:action=>"index", :controller=>"admin/topics"}
                        POST   /admin/topics(.:format)                                {:action=>"create", :controller=>"admin/topics"}
        new_admin_topic GET    /admin/topics/new(.:format)                            {:action=>"new", :controller=>"admin/topics"}
       edit_admin_topic GET    /admin/topics/:id/edit(.:format)                       {:action=>"edit", :controller=>"admin/topics"}
            admin_topic GET    /admin/topics/:id(.:format)                            {:action=>"show", :controller=>"admin/topics"}
                        PUT    /admin/topics/:id(.:format)                            {:action=>"update", :controller=>"admin/topics"}
                        DELETE /admin/topics/:id(.:format)                            {:action=>"destroy", :controller=>"admin/topics"}
           admin_badges GET    /admin/badges(.:format)                                {:action=>"index", :controller=>"admin/badges"}
                        POST   /admin/badges(.:format)                                {:action=>"create", :controller=>"admin/badges"}
        new_admin_badge GET    /admin/badges/new(.:format)                            {:action=>"new", :controller=>"admin/badges"}
       edit_admin_badge GET    /admin/badges/:id/edit(.:format)                       {:action=>"edit", :controller=>"admin/badges"}
            admin_badge GET    /admin/badges/:id(.:format)                            {:action=>"show", :controller=>"admin/badges"}
                        PUT    /admin/badges/:id(.:format)                            {:action=>"update", :controller=>"admin/badges"}
                        DELETE /admin/badges/:id(.:format)                            {:action=>"destroy", :controller=>"admin/badges"}
         admin_students GET    /admin/students(.:format)                              {:action=>"index", :controller=>"admin/students"}
                        POST   /admin/students(.:format)                              {:action=>"create", :controller=>"admin/students"}
      new_admin_student GET    /admin/students/new(.:format)                          {:action=>"new", :controller=>"admin/students"}
     edit_admin_student GET    /admin/students/:id/edit(.:format)                     {:action=>"edit", :controller=>"admin/students"}
          admin_student GET    /admin/students/:id(.:format)                          {:action=>"show", :controller=>"admin/students"}
                        PUT    /admin/students/:id(.:format)                          {:action=>"update", :controller=>"admin/students"}
                        DELETE /admin/students/:id(.:format)                          {:action=>"destroy", :controller=>"admin/students"}

誰にもアイデアはありますか?お時間を割いていただきありがとうございます!

4

1 に答える 1

0

多くの髪を引っ張った後、私は問題と解決策を見つけました.

その理由は、 でオーバーライドdef resourceし、ApplicationHelper常に を返すようにしたためStudentです。def resourceしたがって、次のようにオーバーライドする必要がありました。

def resource
    @resource = Badge.find_by_id(params[:id]) || Badge.new
end

そして、すべてが再び機能します。なぜ以前に失敗しなかったのかはわかりません。:(

于 2011-08-29T05:56:46.043 に答える