我有在FLE new.html.erb桶應用了一個問題:未定義的方法`articles_path」 <#<類別:0xb4107fc0>:0xb498bf48>
<%= form_for @article do |f| %>
<%= f.text_field :title %>
<%= f.text_area :text %>
<%= f.submit %>
<% end %>
我的routes.rb具有:
resources :atricles
我static_pages_controller.rb具有代碼:
def manager
@contact_messages = ContactForm.all
@item = Item.new
@items = Item.all
@article = Article.new
end
我articles_controller.rb是:
class ArticlesController < ApplicationController
def new
@article = Article.new
end
def create
@article = Article.new article_params
@article.save
end
private
def article_params
params.require(:article).permit(:title, :text)
end
end
我遷移文件是:
class CreateArticles < ActiveRecord::Migration
def change
create_table :articles do |t|
t.string :title
t.text :text
t.timestamps null: false
end
end
end
我的應用程序/模型/ article.rb是:
class Article < ActiveRecord::Base
end
感謝
謝謝,這有幫助! :) – verrom