I'm building a simple chat app based on this rails cast. I'm following along fine, but when I go to localhost, I get an error "uninitialized constant MessagesController::Message". This is generally a simple fix, but I have spent over an hour looking for the fix and I cannot see it. Here is my code;
messages_controller
class MessagesController < ApplicationController
def index
@messages = Message.all
end
def create
@message = Message.create!(params[:message])
PrivatePub.publish_to("/messages/new", "alert('#{@message.content}');")
end
end
model (message.rb)
class Message
end
index & message form (index.html.erb);
<h1>Hack Chat</h1>
<ul id="chat">
<%= render @messages %>
</ul>
<%= form_for Message.new, remote: true do |f| %>
<%= f.text_field :content %>
<%= f.submit "Send" %>
<% end %>
<%= subscribe_to "/messages/new" %>
routes.rb;
Hackchat::Application.routes.draw do
root to: 'messages#index'
resources :messages
end
gemfile;
source 'https://rubygems.org'
gem 'rails', '4.0.0'
gem 'sqlite3'
group :assets do
gem 'sass-rails', '~> 4.0.0'
gem 'uglifier', '>= 1.3.0'
gem 'coffee-rails', '~> 4.0.0'
end
gem 'jquery-rails'
gem 'private_pub'
gem "thin", "~> 1.6.1"
I have checked every possible thing I could think of as to why I would be getting this error, and I really do not know why. Any help would be much appreciated.
Also, for using private pub, do I have to run two terminal windows, one running rails server, and the other running faye?