制作文章时,Cloud 9 ruby​​ on rails错误

时间:2017-08-10 23:47:33

标签: ruby-on-rails ruby cloud9-ide cloud9

我收到的错误是:

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]

1 个答案:

答案 0 :(得分:0)

我认为您尚未在模型文件夹中创建文章模型。因此,它无法创建新对象。 在模型文件夹中创建一个文件:

class Article < ApplicationRecord

end

然后尝试在文章

上创建.new命令
Article.new