出于某种原因,我的 redirect_to 操作不再在我的 Rails 4 应用程序中运行?我得到的错误是:
Missing template posts/create
职位控制器
def create
@post = current_user.posts.build(post_params)
if @post.save
redirect_to @post
end
end
def show
@post = Post.find(params[:id])
end
def new
@post = Post.new
end
def index
redirect_to root_path
end
private
def post_params
params.require(:post).permit(:content, :community_id, :user_id, :photo, :photo_file_name)
end
路线
resources :posts do
member do
post :create
end
end