Created
November 28, 2016 07:50
-
-
Save misuchiru/4c893c751124c9b499a62a79b2d146f5 to your computer and use it in GitHub Desktop.
This file contains 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> | |
<head> | |
<title>PerryHaHaのBlog 後台管理</title> | |
<%= csrf_meta_tags %> | |
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1" /> | |
<meta name="viewport" content="width=device-width, initial-scale=1.0"> | |
<%= stylesheet_link_tag 'application', media: 'all', 'data-turbolinks-track': 'reload' %> | |
<%= render '/common/css' %> | |
<%= javascript_include_tag 'application', 'data-turbolinks-track': 'reload' %> | |
</head> | |
<body class="dashboad-top"> | |
<%= render '/common/topNavbar' %> | |
<section id="blog-full-width"> | |
<div class="container"> | |
<div class="row"> | |
<div class="col-md-12"> | |
<%= yield %> | |
<div id='remote_container'></div> | |
<div class="text-center"> | |
<%= will_paginate @paginate, renderer: BootstrapPagination::Rails if @paginate %> | |
</div> | |
</div> | |
</div> | |
</div> | |
</section> | |
<%= render '/common/js' %> | |
</body> | |
</html> |
This file contains 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 Dashboard::PostsController < Dashboard::AdminController | |
before_action :set_post, only: [:show, :edit, :update, :destroy] | |
# GET /posts | |
# GET /posts.json | |
def index | |
@posts = @paginate = Post.order('id DESC').paginate(:page => params[:page]) | |
end | |
# GET /posts/1 | |
# GET /posts/1.json | |
def show | |
end | |
# GET /posts/new | |
def new | |
@post = current_user.posts.new | |
end | |
# GET /posts/1/edit | |
def edit | |
end | |
# POST /posts | |
# POST /posts.json | |
def create | |
@post = current_user.posts.new(post_params) | |
if @post.save | |
redirect_to dashboard_posts_path, notice: 'Post was successfully created.' | |
else | |
render :new | |
end | |
end | |
# PATCH/PUT /posts/1 | |
# PATCH/PUT /posts/1.json | |
def update | |
if @post.update(post_params) | |
redirect_to dashboard_posts_path, notice: 'Post was successfully updated.' | |
else | |
render :edit | |
end | |
end | |
# DELETE /posts/1 | |
# DELETE /posts/1.json | |
def destroy | |
@post.destroy | |
redirect_to dashboard_posts_path, notice: 'Post was successfully destroyed.' | |
end | |
private | |
# Use callbacks to share common setup or constraints between actions. | |
def set_post | |
@post = current_user.posts.find(params[:id]) | |
end | |
# Never trust parameters from the scary internet, only allow the white list through. | |
def post_params | |
params.require(:post).permit(:title, :body, :cate_id, :status, :tag_list) | |
end | |
end |
This file contains 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
json.extract! @post, :id, :title, :created_at, :updated_at | |
json.url post_url(@post, format: :json) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment