我使用與Rails的入門http://tutorials.jumpstartlab.com/projects/blogger.htmlNoMethodError在文章#顯示
我已經完成了教程,現在我用我做了什麼,爲學校工作建立網站教程我只想補充分貝的「數據」文件/遷移/ 20161005160810_create_articles.rb,但我真的收到此消息錯誤
Showing /home/ubuntu/workspace/app/views/articles/show.html.erb where line #12 raised:
undefined method `data' for #<Article:0x007f8bcab2cfe8>
Extracted source (around line #12):
<p>
<strong>Data:</strong>
<%= @article.data %>
</p>
和我articles_controller是這樣
class ArticlesController < ApplicationController
http_basic_authenticate_with name: "mateus", password: "mateus", except: [:index, :show]
def index
@articles = Article.all
end
def show
@article = Article.find(params[:id])
end
def new
@article = Article.new
end
def edit
@article = Article.find(params[:id])
end
def create
@article = Article.new(article_params)
if @article.save
redirect_to @article
else
render 'new'
end
end
def update
@article = Article.find(params[:id])
if @article.update(article_params)
redirect_to @article
else
render 'edit'
end
end
def destroy
@article = Article.find(params[:id])
@article.destroy
redirect_to articles_path
end
def article_params
params.require(:article).permit(:title, :text, :data)
end
end
有人可以幫我嗎?
EDIT1:我以前rake db:migrate:status
然後我得到這個:
mateusjs:~/workspace (master) $ rake db:migrate:status
database: app_development
Status Migration ID Migration Name
--------------------------------------------------
up 20161005160810 Create articles
up 20161005185521 Create comments
up 20170209222858 Parte2
我忘了mencion比我使用Cloud9 –