This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class AddFeaturedToAlbums < ActiveRecord::Migration | |
def change | |
add_column :albums, :featured, :boolean, default: false | |
end | |
end |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
App.albums.where({ featured: true }); | |
// [] |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
App.Collections.Albums = Backbone.Collection.extend | |
model: App.Models.Album | |
url: "/users/2/albums" | |
featured: -> | |
@where(featured: true) | |
App.AlbumsListView = Backbone.View.extend | |
el: '#featured' | |
initialize: -> | |
@listenTo @collection, 'sync', @render |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
%script | |
App.userId = "#{params[:user_id]}" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
.featured-albums.panel | |
%ul#featured{ data: { user-id: params[:user_id] } } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
App.Collections.Albums = Backbone.Collection.extend | |
model: App.Models.Album | |
url: -> | |
userId = $('#featured').data('user-id') | |
"/users/#{userId}/albums" | |
featured: -> | |
@where(featured: true) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
App.AlbumItemView = Backbone.View.extend | |
tagName: 'li' | |
template: _.template "<a href='/users/<%= user_id %>/albums/<%= id %>'><%= title %></a>" | |
render: -> | |
@$el.html @template @model.attributes | |
this |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# app/controllers/application_controller.rb | |
class ApplicationController < ActionController::Base | |
… | |
before_filter :vary_headers | |
… | |
private | |
def vary_headers | |
response.headers["Vary"]= "Accept" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// application.css.sass | |
.unfeature | |
margin-left: 8px | |
.featured-albums | |
padding: 10px | |
width: 50% |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
events: | |
'click .unfeature': 'unfeature' |