【发布时间】:2017-02-09 22:04:31
【问题描述】:
我正在使用 Rails 入门教程http://tutorials.jumpstartlab.com/projects/blogger.html
我已经完成了教程,现在我正在使用我所做的为学校作业创建一个站点,我只想在 db/migrate/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
【问题讨论】:
-
我忘了比我使用 Cloud9
标签: ruby-on-rails ruby show nomethoderror