云9红宝石,同时使文章
我得到一个错误,指出:云9红宝石,同时使文章
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
我不知道如何使文章的模型,如果我没有我不知道要放什么东西在那里...显示,如果你告诉我如何[在这里输入的形象描述]我将不胜感激[1]
我想你还没有在模型文件夹中创建Article模型。因此它不能创建一个新的对象。 在你的模型文件夹此创建一个文件:
class Article < ApplicationRecord
end
,然后尝试在第创建。新的命令
Article.new
所以我必须在我的模型文件夹中创建articles.rb文件? –
我尝试了我所理解的答案: class Article
yes,但型号名称总是单数,控制器名称总是复数,在您的案例中,型号名称为'article.rb '和控制器名称是'articles_controller'。 –
'类文章