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. docker鏡像push報錯2. Docker for Mac 創建的dnsmasq容器連不上/不工作的問題3. javascript - URL中有#號如何來獲取參數啊? nodejs4. docker不顯示端口映射呢?5. angular.js - angular內容過長展開收起效果6. docker容器呢SSH為什么連不通呢?7. 關于docker下的nginx壓力測試8. python - Django表單Form.save()問題9. python - 想要看Exception實現的源碼在什么位置?10. 新手求教python3如何把dict循環寫入csv文件(在進行爬蟲時遇到的問題)?
