我得到这个错误,但我已经在控制器中定义我的方法,我是新来的红宝石,我应该怎么做能帮我摆脱错误出现在该@post所述控制器被未定义未定义的局部变量或方法'后”为#<PostsController:0x007f76b8ee5be8>
这是我的位指示
class PostsController < ApplicationController
def index
@posts = post.all
end
def show
end
def new
end
def create
end
def edit
end
def update
end
def destroy
end
end
这是我的视图
<h1>regular</h1>
<% @posts.each do |post| %>
<h2> <%= post.username %></h2>
<p><%= post.description %></p>
<% end %>
这是我的迁移
class CreatePosts < ActiveRecord::Migration
def up
create_table :posts do |t|
t.string :username
t.text :description
t.timestamps
end
end
def down
drop_table :posts
end
end
这是我的路线
Rails.application.routes.draw do
resources :posts
您好,欢迎来到SO。请在发布之前尝试解决您的问题。 –
'POST'应该是'POST' – Pavan
@narashima我试图 –