View gist:8f1f24048f8052ee6725
var PostExpanded = React.createClass({ | |
propTypes: { | |
post: React.PropTypes.object, | |
comments: React.PropTypes.array, | |
users: React.PropTypes.array | |
}, | |
render: function() { | |
return ( | |
<div> |
View gist:7505774
# app/models/comment.rb | |
class Comment < ActiveRecord::Base | |
include TrackableObserver | |
belongs_to :user | |
has_many :activities, as: :trackable | |
end | |
# app/models/like.rb | |
class Like < ActiveRecord::Base |
View gist:7505705
# config/application.rb | |
config.autoload_paths << "#{config.root}/app/models/observers" | |
config.active_record.observers = :trackable_observer | |
# app/models/comment.rb | |
class Comment < ActiveRecord::Base | |
belongs_to :user | |
has_many :activities, as: :trackable | |
end |
View gist:7505406
# config/application.rb | |
config.autoload_paths << "#{config.root}/app/models/observers" | |
config.active_record.observers = :user_observer | |
# app/models/user.rb | |
class User < ActiveRecord::Base | |
has_many :galleries | |
end | |
# app/models/observers/user_observer.rb |
View gist:7505333
# app/models/user.rb | |
class User < ActiveRecord::Base | |
include UserObserver | |
has_many :galleries | |
end | |
# /app/models/concerns/user_observer.rb | |
module UserObserver | |
extend ActiveSupport::Concern | |
View gist:6977242
class Document < ActiveRecord::Base | |
# Environment-specific direct upload url verifier screens for malicious posted upload locations. | |
DIRECT_UPLOAD_URL_FORMAT = %r{\Ahttps:\/\/s3\.amazonaws\.com\/myapp#{!Rails.env.production? ? "\\-#{Rails.env}" : ''}\/(?<path>uploads\/.+\/(?<filename>.+))\z}.freeze | |
belongs_to :user | |
has_attached_file :upload | |
validates :direct_upload_url, presence: true, format: { with: DIRECT_UPLOAD_URL_FORMAT } | |
View gist:9e69529b0d835902f33d
class PostQuery | |
attr_accessor :relation | |
ALLOWED_SORT_ATTRS = ["title", "updated_at"] | |
# @example PostQuery.new.relation.recent.sorted("title", "DESC") | |
# @example PostQuery.new(user.posts).relation.recent.sorted("title", "DESC") | |
# | |
def initialize(relation = nil) |
View gist:7226f8e0ea3800a1f517
<!DOCTYPE html> | |
<html lang="en"> | |
<head> | |
<title>Dynamic Segment Bug</title> | |
</head> | |
<body> | |
<div id="app"></div> | |
<script src="https://cdnjs.cloudflare.com/ajax/libs/react/0.12.2/JSXTransformer.js"></script> | |
<script src="https://cdnjs.cloudflare.com/ajax/libs/react/0.12.2/react.min.js"></script> |
View gist:a9e17127cdec1b08a2b4
# posts/show.html.erb | |
<%= react_component("ShowPost", render(template: 'posts/show.json.jbuilder')) %> | |
# posts/show.json.jbuilder | |
json.post do | |
json.extract!(@post, :id, :user_id, :title, :body) | |
end | |
json.comments(@comments) do |comment| | |
json.extract!(comment, :id, :user_id, :body) |
View gist:487b6f94c615ae75e636
// WORKING VERSION | |
var Table = React.createClass({ | |
getDefaultProps: function() { | |
return { | |
columns: [ | |
{ propName: 'id', name: 'ID' }, | |
{ propName: 'name', name: 'Name' } | |
] | |
}; | |
}, |
NewerOlder