我收到了一个错误,内容是:
https://i.stack.imgur.com/7mw12.png (这是错误的图像)
new.html.erb
<h1> Create an article </h1>
<%= form_for @article do |f| %>
<p>
<%= f.label :title %>
<%=f.text_field :title %>
</p>
<% end %>articles_controller.rb
class ArticlesController < ApplicationController
def new
@article = Article.new
end
end 这是我的routes.rb
Rails.application.routes.draw do
# The priority is based upon order of creation: first created -> highest
priority.
# See how all your routes lay out with "rake routes".
# You can have the root of your site routed with "root"
# root 'welcome#index'
root 'pages#home'
get 'about', to: 'pages#about'
resources :articles我不知道如何制作文章模型,如果我做了,我就不知道在里面放什么了……如果您告诉我如何在此处输入图像描述,我将不胜感激
发布于 2017-08-11 21:08:22
我想你还没有在models文件夹中创建文章模型。因此,它不能创建新对象。在models文件夹中创建一个文件:
class Article < ApplicationRecord
end然后尝试在文章上创建.new命令
Article.newhttps://stackoverflow.com/questions/45624997
复制相似问题