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. 為什么我ping不通我的docker容器呢???2. android - webview 自定義加載進度條3. 將SQLServer數據同步到MySQL 用什么方法?4. 什么操作會導致mysql的binlog_size快速變大?5. numpy - python [:,2][:,None]是什么意思6. linux - openSUSE 上,如何使用 QQ?7. javascript - 微信音樂分享8. mysql優化 - 如何解決 MySQL 導入約 2G 的 SQL 報錯?9. javascript - vue引入微信jssdk 配置在哪個生命周期調取接口配置?10. javascript - 微信小程序限制加載個數
