Ruby on rails 钢轨单位化常数

Ruby on rails 钢轨单位化常数,ruby-on-rails,Ruby On Rails,我正在遵循给出的教程,我被困在第5.6小节的末尾 每次单击表单上的“提交”时,都会出现以下错误: NameError in PostsController#create uninitialized constant PostsController::Post 5.7从添加开始 post GET/posts/:id:将postsshow格式化为代码。我不知道在哪里添加这个,或者这是否会对我得到的错误产生任何影响 这有什么办法 编辑: 添加 posts.rb class Post < Act

我正在遵循给出的教程,我被困在第5.6小节的末尾

每次单击表单上的“提交”时,都会出现以下错误:

NameError in PostsController#create
uninitialized constant PostsController::Post
5.7从添加开始

post GET/posts/:id:将postsshow格式化为代码。我不知道在哪里添加这个,或者这是否会对我得到的错误产生任何影响

这有什么办法

编辑: 添加 posts.rb

class Post < ActiveRecord::Base
  attr_accessible :string, :text
end
posts\u controller.rb

class PostsController < ApplicationController

  def create
    @post = Post.new(post_params)

    @post.save
    redirect_to @post
  end
  def show
    @post = Post.find(params[:id])
  end

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

显示您的PostsController源代码。您可以发布app/model/post.rb和app/controller/posts\u controller.rb吗?添加了posts.rb和posts\u controller.rb源代码。您可以发布日志中的确切错误吗?您的模型文件应命名为post.rb而不是posts.rb