Ruby on rails 未知操作操作';创建';找不到PostsController的 class PostsController“已创建” 结束 私有的 def post_参数 参数要求(:职位)许可证(:职务,:正文) 结束 结束

Ruby on rails 未知操作操作';创建';找不到PostsController的 class PostsController“已创建” 结束 私有的 def post_参数 参数要求(:职位)许可证(:职务,:正文) 结束 结束,ruby-on-rails,ruby-on-rails-4,Ruby On Rails,Ruby On Rails 4,您的方法需要小写。将Create更改为Create我是rails新手,遇到错误:未知操作无法找到PostsController的操作“Create”在终端中使用rake routes检查您的路由,请确保您的routes.rb中有资源:posts。其次,create也应该是小写的。 class PostsController < ApplicationController def index end def new end def Create @post = P

您的方法需要小写。将
Create
更改为
Create

我是rails新手,遇到错误:未知操作无法找到PostsController的操作“Create”在终端中使用
rake routes
检查您的路由,请确保您的routes.rb中有
资源:posts
。其次,
create
也应该是小写的。
class PostsController < ApplicationController
  def index
  end
  def new
  end
  def Create
    @post = Post.new(post_params)
    @post.save

    redirect_to @post, :notice=> "created"
  end

  private
  def post_params
    params.require(:post).permit(:title, :body)
  end
end