0
私はレール3.2.3を使用しており、HABTM関係に問題があります。Ruby on Rails - HABTM NoMethodError
基本的に私はUserモデルを持っており、HABTMにはRoleモデルがあります。
すべてうまくいきますが、UserモデルとHotelモデルの間に別のHABTMリレーションシップを追加する必要があります。私は私のページを実行しようとすると、私は(テール-fログ/ development.log)を得るため除き
:
NoMethodError (undefined method `[]' for :hotels:Symbol):
app/models/user.rb:7
config/routes.rb:6
config/routes.rb:1
マイルート:
Oops::Application.routes.draw do #this is my line 1
get "managers/index"
root :to => "hotels#index"
devise_for :users #this is my line 6
resources :roles
resources :users
resources :managers
resources :hotels
ActiveAdmin.routes(self)
マイUserモデル:
devise :database_authenticatable, :recoverable, (...)
has_and_belongs_to_many :roles, :hotels #This is my line 7, if I delete :hotels and all its references in this HABTM relationship, everything works
accepts_nested_attributes_for :roles
attr_accessible :username, :email, :password, :password_confirmation, :remember_me, :role_ids, :hotel_attributes
マイホテルモデル:
has_and_belongs_to_many :facilities, :users
has_one :address
accepts_nested_attributes_for :facilities, :address, :users
attr_accessible <all hotel attributes>, :facility_ids, :address_attributes, :user_ids
この新しい関係まですべてがうまくいっていました。私はプロジェクトのページを全く動かすことができません。 ヒント?
ありがとうございます。