路由错误?也许

时间:2010-12-03 19:53:15

标签: ruby-on-rails join

我在尝试查看频道控制器时遇到此错误。

  

未初始化的常量   通道:: MessagesChannel

我猜它会出现路由错误,但我不知道如何修复它。

class Message < ActiveRecord::Base
  has_many :messages_channel , :dependent => :destroy
  has_many :channels, :through => :mesages_channels

  #joins between users and messages
  has_many :user_messages
  has_many :users, :through => :user_messages
end

class Channel < ActiveRecord::Base
  has_many :messages_channels , :dependent => :destroy
  has_many :messages ,:through => :messages_channels
  has_many :channel_mods , :dependent => :destroy
  has_many :moderators , :class_name =>"User", :through => :channel_mods
  has_many :users_channels , :dependent => :destroy
  has_many :users, :through => :users_channels

end

class MessagesChannels < ActiveRecord::Base
  belongs_to :message
  belongs_to :channel
end

SeniorProject::Application.routes.draw do

  resources :users 

  resources :channels do
    resources :messages
  end

  resources :users, :user_sessions
  match 'login' => 'user_sessions#new', :as => :login
  match 'logout' => 'user_sessions#destroy', :as => :logout
  match ':controller(/:action(/:id(.:format)))'
  #match 'subscribe' =>'channels#subscribe', :as => :subscribe

  match 'subscribe/:channel_id/:user_id' =>'channels#subscribe', :as => :subscribe

  root :to => 'channels#index', :as => :listchannels



end

1 个答案:

答案 0 :(得分:1)

模型 MessagesChannels 不应该是复数,而应该是单数。