2
我想在軌道4使用嵌套的資源,但得到以下錯誤:嵌套資源錯誤:自動加載常數檢測到循環依賴性
RuntimeError (Circular dependency detected while autoloading constant Client::Website::ClientWebsitesController)
所以我這是由裝置和後我創建了一個客戶端模型有一個網站模型。這種關係是一對多的關係。
數據庫:
create_table(:clients) do |t|
## Database authenticatable
t.string :email, :null => false, :default => ""
t.string :encrypted_password, :null => false, :default => ""
## Recoverable
t.string :reset_password_token
t.datetime :reset_password_sent_at
## Rememberable
t.datetime :remember_created_at
## Trackable
t.integer :sign_in_count, :default => 0, :null => false
t.datetime :current_sign_in_at
t.datetime :last_sign_in_at
t.string :current_sign_in_ip
t.string :last_sign_in_ip
## Confirmable
# t.string :confirmation_token
# t.datetime :confirmed_at
# t.datetime :confirmation_sent_at
# t.string :unconfirmed_email # Only if using reconfirmable
## Lockable
# t.integer :failed_attempts, :default => 0, :null => false # Only if lock strategy is :failed_attempts
# t.string :unlock_token # Only if unlock strategy is :email or :both
# t.datetime :locked_at
t.timestamps
end
create_table :websites do |t|
t.string :host
t.string :name
t.text :description
t.text :code #integration code, that field will be filled after the website is created
t.integer :client_id
t.timestamps
end
型號:
class Client < ActiveRecord::Base
# Include default devise modules. Others available are:
# :confirmable, :lockable, :timeoutable and :omniauthable
devise :database_authenticatable, :registerable,
:recoverable, :rememberable, :trackable, :validatable
has_many :websites
has_many :partner_profits
belongs_to :subscription_plan
end
class Website < ActiveRecord::Base
belongs_to :client
has_many :questions
has_one :popup_skin
end
路線:
devise_for :admins
devise_for :partners
devise_for :clients
resources :clients do
resources :websites, controller: 'client/website/client_websites'
end
root to: 'frontend#index'
我從來沒有使用嵌套的資源,任何想法我缺少什麼嗎?試圖解決第二日已經:(
提前感謝的問題;!)
我想像的問題會隨着你的'客戶::網站:: ClientWebsitesController'文件 這是一個控制器 - 你確定它設置正確? 此外,你應該真的提供這個控制器的代碼和你引用它的視圖/控制器(這些會告訴你在調用它時可能遇到的任何問題) –
當問題出現時,有時會出現這個特定的錯誤信息與依賴關係無關 - 請參閱此問題進行討論:https://github.com/rails/rails/issues/12394 您需要檢查控制器文件是否存在其他錯誤(引用常量,不存在是常見的觸發器)。如果你仍然無法打開任何東西,請將它張貼在這裏。 –
@MattJones謝謝。這導致我以我的模特班的名字找到了一個錯字。 –