今までは普通にアクセスできていたが、急にできなくなりました。
http://okerra.hatenablog.com/entry/2018/01/03/082902
このサイトを例に該当箇所がないか探したが特にみつかりませんでした。
エラーの前後でモデルは変更を加えていません。
エラーの前後にcyberduckのアップデートインストールが失敗しました。
それが原因ですか?
考えられる原因は何でしょうか
大変困っています。
ーーーーーーーーーーーー↓追加部分
githubのアドレスも載せます
https://github.com/tuna114sakana/mylibrary
Ruby
1class PostsController < ApplicationController 2 before_action :authenticate_user 3 4 def index 5 @posts=Post.all 6 end 7 8 def new 9 @post=Post.new 10 @category=Category.find_by(id: params[:id]) 11 @classification=Classification.new 12 end 13 14 def create 15 @post=Post.new( 16 name: params[:name], 17 content: params[:content], 18 user_id: @current_user.id 19 ) 20 @post.save 21 @category=Category.find_by(id: params[:category]) 22 @classification=Classification.new( 23 category_id: @category.id, 24 post_id: @post.id 25 ) 26 27 if @classification.save 28 redirect_to("/posts/index") 29 else 30 @erorr_message="全ての項目をうめてください" 31 render("posts/new") 32 end 33 if params[:image] 34 @post.image_name = "#{@post.id}.jpg" 35 image = params[:image] 36 File.binwrite("/home/vagrant/mylibrary/myapp/public/post_images/#{@post.image_name}",image.read) 37 end 38 end 39 40 def show 41 @post=Post.find_by(id: params[:id]) 42 @user=@post.user 43 @category=Post.find_by(id: params[:id]).categories 44 end 45 46 def destroy 47 @post=Post.find_by(id: params[:id]) 48 @post.destroy 49 redirect_to("/posts/index") 50 end 51 52 def edit 53 @post=Post.find_by(id: params[:id]) 54 @category=Post.find_by(id: params[:id]).categories 55 @classification=Classification.new 56 end 57 58 def update 59 @post=Post.find_by(id: params[:id]) 60 @post.content=params[:content] 61 @post.save 62 63 @category=Category.find_by(id: params[:add_category]) 64 @classification=Classification.new( 65 category_id: @category.id, 66 post_id: @post.id 67 ) 68 if @classification.save 69 redirect_to("posts/index") 70 else 71 render("posts/edit") 72 end 73 74 def category 75 @category=Category.find_by(name: params[:name]) 76 @post=Category.find_by(id: @category.id).posts 77 end 78 79end 80
posts_controller の頭10行ぐらい見せて下さい
posts_controllerを載せました。githubのURLも載せたので見てみてください。
よろしくお願いします。m(__)m
回答2件
あなたの回答
tips
プレビュー