I am making a simple chat app based on this railscast. I posted another question about this, but I stupidly did not add a model, and then I named it incorrectly.
However, that is now fixed. The thing is, I am not even sure if I need a database at all. I was originally going to finish this, then upload it on heroku to just play around with. I don't want to store the messages, but if it is necessary then I will. Here is my code.
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" %>
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;
class Message < ActiveRecord::Base
end
routes;
Hackchat::Application.routes.draw do
root to: 'messages#index'
resources :messages
end
gemfile;
source 'https://rubygems.org'
gem 'rails', '4.0.0'
gem "rake", "~> 10.1.1"
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 ran bundle exec rake db:create, bundle exec rake db:migrate and I still get the error;
ActionView::Template::Error (SQLite3::SQLException: no such table: messages: SELECT "messages".* FROM "messages"):
1: <h1>Hack Chat</h1>
2:
3: <ul id="chat">
4: <%= render @messages %>
5: </ul>
6:
7: <%= form_for Message.new, remote: true do |f| %>
app/views/messages/index.html.erb:4:in `_app_views_messages_index_html_erb__3441634471849115078_70351149151260'
Any and all help would be greatly appreciated.