Skip to content

Instantly share code, notes, and snippets.

View lacides's full-sized avatar

Lacides Charris lacides

  • Koombea
  • Barranquilla, Colombia
View GitHub Profile
(function($) {
Anotherchat.Views.Message = Backbone.View.extend({
tagName: 'div',
template: JST["messages/message"],
render: function(){
$(this.el).html(this.template({message: this.model}));
return this;
}
});
})(jQuery);
(function($) {
Anotherchat.Collections.Messages = Backbone.Collection.extend({
url: '/messages'
});
})(jQuery);
(function($) {
Anotherchat.Models.Message = Backbone.Model.extend({});
})(jQuery);
window.Anotherchat = {
Models: {},
Collections: {},
Views: {},
Routers: {},
init: function() {
alert('Hello from Backbone!');
}
};
source 'https://rubygems.org'
gem 'rails', '3.2.3'
# Bundle edge Rails instead:
# gem 'rails', :git => 'git://github.com/rails/rails.git'
gem 'pg'
gem 'devise'
<html>
<head>
<title>Backbone.js and Server Sent Events</title>
<meta charset="utf-8" />
<script src="/javascripts/jquery.min.js"></script>
<script src="/javascripts/bootstrap.min.js"></script>
<script src="/javascripts/navigation.js"></script>
<link rel="stylesheet" href="/stylesheets/bootstrap.min.css">
<link rel="stylesheet" href="/stylesheets/bootstrap-responsive.min.css">
var messages = Backbone.Collection.extend({
model: message,
url: '/messages'
});
var message = Backbone.Model.extend({});
<div id="app">
</div>
class MessagesController < ApplicationController
before_filter :authenticate_user!
def index
@messages = Message.all
respond_to do |format|
format.html
format.json { render json: @messages }
end
end