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 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) |
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
<!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> |
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
# 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) |
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
// WORKING VERSION | |
var Table = React.createClass({ | |
getDefaultProps: function() { | |
return { | |
columns: [ | |
{ propName: 'id', name: 'ID' }, | |
{ propName: 'name', name: 'Name' } | |
] | |
}; | |
}, |
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
var PostExpanded = React.createClass({ | |
propTypes: { | |
post: React.PropTypes.object, | |
comments: React.PropTypes.array, | |
users: React.PropTypes.array | |
}, | |
render: function() { | |
return ( | |
<div> |
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
# Activate the gem you are reporting the issue against. | |
gem 'activerecord', '4.1.7' | |
require 'active_record' | |
require 'minitest/autorun' | |
require 'logger' | |
# Ensure backward compatibility with Minitest 4 | |
Minitest::Test = MiniTest::Unit::TestCase unless defined?(Minitest::Test) | |
# This connection will do for database-independent bug reports. |
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/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 |
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
# 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 |
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
# 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 |
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/models/user.rb | |
class User < ActiveRecord::Base | |
include UserObserver | |
has_many :galleries | |
end | |
# /app/models/concerns/user_observer.rb | |
module UserObserver | |
extend ActiveSupport::Concern | |
NewerOlder