Commit 46338a4a by tady

spacified_dateを一覧に表示

parent 3dc9d1f6
...@@ -30,3 +30,5 @@ ...@@ -30,3 +30,5 @@
/backup /backup
/script/backup.sh /script/backup.sh
.rbenv-gemsets
...@@ -132,3 +132,5 @@ gem 'newrelic_rpm' ...@@ -132,3 +132,5 @@ gem 'newrelic_rpm'
gem 'breadcrumble' gem 'breadcrumble'
gem 'slim' gem 'slim'
gem 'annotate', ">=2.6.0"
...@@ -37,6 +37,9 @@ GEM ...@@ -37,6 +37,9 @@ GEM
addressable (2.3.6) addressable (2.3.6)
ancestry (2.0.0) ancestry (2.0.0)
activerecord (>= 3.0.0) activerecord (>= 3.0.0)
annotate (2.6.2)
activerecord (>= 2.3.0)
rake (>= 0.8.7)
arel (4.0.2) arel (4.0.2)
ast (1.1.0) ast (1.1.0)
atomic (1.1.16) atomic (1.1.16)
...@@ -364,6 +367,7 @@ PLATFORMS ...@@ -364,6 +367,7 @@ PLATFORMS
DEPENDENCIES DEPENDENCIES
action-gmailer! action-gmailer!
ancestry ancestry
annotate (>= 2.6.0)
aws-sdk aws-sdk
better_errors better_errors
binding_of_caller binding_of_caller
......
...@@ -2,6 +2,6 @@ class FlowController < ApplicationController ...@@ -2,6 +2,6 @@ class FlowController < ApplicationController
before_action :require_login before_action :require_login
def show def show
@posts = Post.where(is_draft: false).order(updated_at: :desc).limit(20).decorate @posts = Post.includes(:tags, :author).where(is_draft: false).order(updated_at: :desc).limit(20).decorate
end end
end end
...@@ -27,4 +27,12 @@ class PostDecorator < Draper::Decorator ...@@ -27,4 +27,12 @@ class PostDecorator < Draper::Decorator
end end
end end
def display_specified_date
if model.specified_date
model.specified_date.strftime('%Y-%m-%d')
else
''
end
end
end end
# == Schema Information
#
# Table name: comments
#
# id :integer not null, primary key
# author_id :integer
# post_id :integer
# body :text
# created_at :datetime
# updated_at :datetime
#
class Comment < ActiveRecord::Base class Comment < ActiveRecord::Base
belongs_to :author, class_name: 'User' belongs_to :author, class_name: 'User'
belongs_to :post belongs_to :post
......
# == Schema Information
#
# Table name: posts
#
# id :integer not null, primary key
# title :string(255)
# body :text
# author_id :integer
# created_at :datetime
# updated_at :datetime
# is_draft :boolean default(FALSE)
# specified_date :date
#
# specified_dateは特定の日付を指定したい場合に使用
class Post < ActiveRecord::Base class Post < ActiveRecord::Base
has_many :post_tags has_many :post_tags
has_many :tags, through: :post_tags has_many :tags, through: :post_tags
......
# == Schema Information
#
# Table name: post_tags
#
# id :integer not null, primary key
# post_id :integer not null
# tag_id :integer not null
# created_at :datetime
# updated_at :datetime
#
class PostTag < ActiveRecord::Base class PostTag < ActiveRecord::Base
belongs_to :post belongs_to :post
belongs_to :tag belongs_to :tag
......
# == Schema Information
#
# Table name: tags
#
# id :integer not null, primary key
# name :string(255)
# created_at :datetime
# updated_at :datetime
# ancestry :string(255)
# body :text
#
class Tag < ActiveRecord::Base class Tag < ActiveRecord::Base
has_many :post_tags has_many :post_tags
has_many :posts, through: :post_tags has_many :posts, through: :post_tags
......
# == Schema Information
#
# Table name: users
#
# id :integer not null, primary key
# name :string(255)
# image_url :string(255)
# created_at :datetime
# updated_at :datetime
# email :string(255) default(""), not null
# encrypted_password :string(255) default(""), not null
# reset_password_token :string(255)
# reset_password_sent_at :datetime
# remember_created_at :datetime
# sign_in_count :integer default(0), not null
# current_sign_in_at :datetime
# last_sign_in_at :datetime
# current_sign_in_ip :string(255)
# last_sign_in_ip :string(255)
# google_auth_token :string(255)
# google_refresh_token :string(255)
# google_token_expires_at :datetime
# nickname :string(255) default(""), not null
#
require 'faraday' require 'faraday'
class User < ActiveRecord::Base class User < ActiveRecord::Base
......
...@@ -4,9 +4,10 @@ ...@@ -4,9 +4,10 @@
a.list-group-item.post-list.mod-hover-hidden data-post-id=post.id href=post_path(post) a.list-group-item.post-list.mod-hover-hidden data-post-id=post.id href=post_path(post)
.container-fluid .container-fluid
.row .row
.col-xs-10 .col-xs-9
h4.text-link #{post.title} h4.text-link #{post.title}
.col-xs-2 .col-xs-3
span.label.label-danger = post.display_specified_date if post.specified_date
small.pull-right small.pull-right
##{post.id} ##{post.id}
.row .row
......
...@@ -8,11 +8,13 @@ ...@@ -8,11 +8,13 @@
span.label.label-success span.label.label-success
a href=tag.decorate.show_path a href=tag.decorate.show_path
| ##{tag.name} | ##{tag.name}
| &nbsp;
span.label.label-info span.label.label-info
a href=(posts_path(q: "@#{@post.author.name}")) a href=(search_path(q: "@#{@post.author.name}"))
| @#{@post.author.name} | @#{@post.author.name}
| &nbsp;
span.label.label-danger span.label.label-danger
a href=(posts_path(q: "date:#{@post.display_date}")) = @post.display_date a href=(search_path(q: "date:#{@post.display_date}")) = @post.display_date
.btn-group.pull-right style=("margin: -7px -12px 0 0;") .btn-group.pull-right style=("margin: -7px -12px 0 0;")
a.btn.btn-primary href=edit_post_path(@post) a.btn.btn-primary href=edit_post_path(@post)
span.glyphicon.glyphicon-pencil span.glyphicon.glyphicon-pencil
......
# == Schema Information
#
# Table name: comments
#
# id :integer not null, primary key
# author_id :integer
# post_id :integer
# body :text
# created_at :datetime
# updated_at :datetime
#
# FactoryGirl.define do # FactoryGirl.define do
# factory :comment_1, class: Comment do # factory :comment_1, class: Comment do
# body 'ruby' # body 'ruby'
......
# == Schema Information
#
# Table name: posts
#
# id :integer not null, primary key
# title :string(255)
# body :text
# author_id :integer
# created_at :datetime
# updated_at :datetime
# is_draft :boolean default(FALSE)
# specified_date :date
#
# Read about factories at https://github.com/thoughtbot/factory_girl # Read about factories at https://github.com/thoughtbot/factory_girl
FactoryGirl.define do FactoryGirl.define do
......
# == Schema Information
#
# Table name: tags
#
# id :integer not null, primary key
# name :string(255)
# created_at :datetime
# updated_at :datetime
# ancestry :string(255)
# body :text
#
# Read about factories at https://github.com/thoughtbot/factory_girl # Read about factories at https://github.com/thoughtbot/factory_girl
FactoryGirl.define do FactoryGirl.define do
......
# == Schema Information
#
# Table name: users
#
# id :integer not null, primary key
# name :string(255)
# image_url :string(255)
# created_at :datetime
# updated_at :datetime
# email :string(255) default(""), not null
# encrypted_password :string(255) default(""), not null
# reset_password_token :string(255)
# reset_password_sent_at :datetime
# remember_created_at :datetime
# sign_in_count :integer default(0), not null
# current_sign_in_at :datetime
# last_sign_in_at :datetime
# current_sign_in_ip :string(255)
# last_sign_in_ip :string(255)
# google_auth_token :string(255)
# google_refresh_token :string(255)
# google_token_expires_at :datetime
# nickname :string(255) default(""), not null
#
FactoryGirl.define do FactoryGirl.define do
factory :alice, class: User do factory :alice, class: User do
name 'Alice' name 'Alice'
......
# == Schema Information
#
# Table name: comments
#
# id :integer not null, primary key
# author_id :integer
# post_id :integer
# body :text
# created_at :datetime
# updated_at :datetime
#
require 'spec_helper' require 'spec_helper'
describe Comment do describe Comment do
......
# == Schema Information
#
# Table name: posts
#
# id :integer not null, primary key
# title :string(255)
# body :text
# author_id :integer
# created_at :datetime
# updated_at :datetime
# is_draft :boolean default(FALSE)
# specified_date :date
#
require 'spec_helper' require 'spec_helper'
describe Post do describe Post do
......
# == Schema Information
#
# Table name: tags
#
# id :integer not null, primary key
# name :string(255)
# created_at :datetime
# updated_at :datetime
# ancestry :string(255)
# body :text
#
require 'spec_helper' require 'spec_helper'
describe Tag do describe Tag do
......
# == Schema Information
#
# Table name: users
#
# id :integer not null, primary key
# name :string(255)
# image_url :string(255)
# created_at :datetime
# updated_at :datetime
# email :string(255) default(""), not null
# encrypted_password :string(255) default(""), not null
# reset_password_token :string(255)
# reset_password_sent_at :datetime
# remember_created_at :datetime
# sign_in_count :integer default(0), not null
# current_sign_in_at :datetime
# last_sign_in_at :datetime
# current_sign_in_ip :string(255)
# last_sign_in_ip :string(255)
# google_auth_token :string(255)
# google_refresh_token :string(255)
# google_token_expires_at :datetime
# nickname :string(255) default(""), not null
#
require 'spec_helper' require 'spec_helper'
describe User do describe User do
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment