2016-07-14 18 views
0

私は少しのRails CMSを書いていますが、ルーティングエラーが多少残っています。まず、Entryという基本モデルを継承しています。私は既存のモデルを編集しようとすると、それは私が、以下の持っている私のroutes.rb CMSでプラグインでは私にエラー編集方法のルーティングエラー

No route matches [PATCH] "/admin/posts/entries" 

を返します。

Multiflora::Engine.routes.draw do 
    root "dashboard#index" 

    scope "/:content_class" do 
    resources :entries 
    end 
end 

とテストアプリの私が持っているroutes.rb

mount Multiflora::Engine, at: '/admin' 

application_controller.rb私も少し経路を微調整しました:

def content_entries_path 
    entries_path(content_class: content_class.tableize) 
end 
helper_method :content_entries_path 

def content_entry_path(entry) 
    entry_path(entry, content_class: content_class.tableize) 
end 
helper_method :content_entry_path 

def new_content_entry_path 
    new_entry_path(content_class: content_class.tableize) 
end 
helper_method :new_content_entry_path 

def edit_content_entry_path(entry) 
    edit_entry_path(entry, content_class: content_class.tableize) 
end 
helper_method :edit_content_entry_path 

そして、私のshow.html.erbに私はこれを持っている:

<%= link_to 'Edit', edit_content_entry_path(@entry) %> 

私はedit_content_entry_pathに移動すると、それは正しく私の編集ページを示しているが、私は編集したエントリを保存しようとすると、それは私に上記のエラーを返します。私はrake routesを実行すると、それは次のように私を返します。

entries GET /:content_class/entries(.:format)   multiflora/entries#index 
     POST /:content_class/entries(.:format)   multiflora/entries#create 
new_entry GET /:content_class/entries/new(.:format)  multiflora/entries#new 
edit_entry GET /:content_class/entries/:id/edit(.:format) multiflora/entries#edit 
entry GET /:content_class/entries/:id(.:format)  multiflora/entries#show 
     PATCH /:content_class/entries/:id(.:format)  multiflora/entries#update 
     PUT /:content_class/entries/:id(.:format)  multiflora/entries#update 
     DELETE /:content_class/entries/:id(.:format)  multiflora/entries#destroy 

答えて

0

ので、エラーが私のedit.html.erbビューにあった - 代わりに

<%= form_for(@entry, as: :entry, url: content_entry_path(@entry)) do |f| %> 

の私が書き直したとき、私は

<%= form_for(@entry, as: :entry, url: entries_path do |f| %> 

を持っていましたそれ、すべてが働いた!

関連する問題