Commit 11d6cac3 by tady

更新時にauthorを上書き, js不具合修正

parent ec627cfe
...@@ -52,6 +52,7 @@ class PostsController < ApplicationController ...@@ -52,6 +52,7 @@ class PostsController < ApplicationController
# PATCH/PUT /posts/1 # PATCH/PUT /posts/1
# PATCH/PUT /posts/1.json # PATCH/PUT /posts/1.json
def update def update
@post.author = current_user
respond_to do |format| respond_to do |format|
if @post.update(post_params) if @post.update(post_params)
......
...@@ -41,22 +41,6 @@ ...@@ -41,22 +41,6 @@
$(function(){ $(function(){
'use strict'; 'use strict';
// Preview post.
var load_preview = function(){
var text = $('#post_body').val();
var csrfToken = $("meta[name='csrf-token']").attr('content');
$.post('/posts/preview.api', {
'text': text,
'authenticity_token': csrfToken
})
.done(function(data){
$('#post_preview').html(data);
});
};
$('#post_body').on('keyup mouseup', load_preview);
// load_preview();
// post list // post list
$('.post-list').on('click', function(e){ $('.post-list').on('click', function(e){
e.preventDefault(); e.preventDefault();
......
...@@ -14,8 +14,8 @@ ...@@ -14,8 +14,8 @@
<p style="text-align:center;"><img src="<%= image_path 'office-space-view.jpg' %>" alt="First slide"></p> <p style="text-align:center;"><img src="<%= image_path 'office-space-view.jpg' %>" alt="First slide"></p>
<div class="container"> <div class="container">
<div class="carousel-caption"> <div class="carousel-caption">
<h1>Example headline.</h1> <h1>らんでぶー</h1>
<p>Note: If you're viewing this page via a <code>file://</code> URL, the "next" and "previous" Glyphicon buttons on the left and right might not load/display properly due to web browser security rules.</p> <p>Googleアカウントでログインしてください。</p>
<p><a class="btn btn-lg btn-primary" href="<%= user_omniauth_authorize_path(:google_oauth2) %>" role="button">Sign up with Google</a></p> <p><a class="btn btn-lg btn-primary" href="<%= user_omniauth_authorize_path(:google_oauth2) %>" role="button">Sign up with Google</a></p>
</div> </div>
</div> </div>
......
...@@ -98,6 +98,26 @@ ...@@ -98,6 +98,26 @@
$('#post_tags').select2({ $('#post_tags').select2({
tags: <%= raw Tag.all.pluck(:name).to_json %> tags: <%= raw Tag.all.pluck(:name).to_json %>
}); });
// Preview post.
var load_preview = function(){
console.log('load_preview')
var text = $('#post_body').val();
var csrfToken = $("meta[name='csrf-token']").attr('content');
$.post('/posts/preview.api', {
'text': text,
'authenticity_token': csrfToken
})
.done(function(data){
$('#post_preview').html(data);
});
};
$('#post_body').on('keyup mouseup', load_preview);
$('#post_body').on('keyup mouseup', function(){
console.log('faij')
});
load_preview();
}); });
</script> </script>
<% end %> <% end %>
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