web - Rails3使用form_for時出現undefined method `*_path’錯誤。
問題描述
使用rails g controller admin::articles index new edit創建controller,使用rails g model article創建的model。 路由為
namespace :admin do resources :articlesend
/app/controllers/admin/articles_controller.rb
class Admin::ArticlesController < ApplicationController def index @articles = Article.all end def new @article = Article.new end def edit @article = Article.find(params[:id]) end
/app/models/article.rb
class Article < ActiveRecord::Base attr_accessible :content, :tag, :titleend
現在想要在new.html.erb使用form_for創建一個表單
<%= form_for(@article) do |f| %><p class='field'> <%= f.label :title %><br /> <%= f.text_field :title %></p><% end %>
結果還只到這里測試的時候就出現了錯誤undefined method `articles_path’,麻煩大家幫忙看看是哪里出了問題。
問題解答
回答1:[:admin, @article]http://guides.rubyonrails.org/form_helpers.html#dealing-with-namespaces
相關文章:
1. 淺談vue生命周期共有幾個階段?分別是什么?2. index.php錯誤,求指點3. 視頻 - html5 video的autoplay 在智能手機上不運作?4. javascript - 百度坐標,返回目標附近有哪些坐標5. css3 - 使用less編譯css后,后期的項目中less是直接放在項目文件中,后期如何維護呢6. css3 - 在css里面,樣式不生效問題7. node.js - 在阿里云搭建vue環境后npm run dev 沒有看到vue歡迎頁面而是 UnhandledPromiseRejection8. javascript - Jquary的contains如何做到精準匹配9. html5 - 前端面試碰到了一個緩存數據的問題,來論壇上請教一下10. javascript - ui-router AngularJS url顯示正常 頁面沒有變化?
