Rails 3.2 和 Mercury 编辑器无法通过编辑/路由找到对象



我的routes.rb

DigitalizmAdmin::Application.routes.draw do
  ## Admin routes
  namespace :mercury do
    resources :images
  end
  mount Mercury::Engine => '/'
  devise_for :admins #, :skip => [:registrations, :passwords]
  namespace :admin do
    root :to => "admin#dashboard"
    resources :categories do
      member { post :mercury_update }
    end
    resources :posts do
      member { post :mercury_update }
    end
    resources :pages do
      member { post :mercury_update }
    end
  end
  ## Regular routes
  root to: "welcome#index"
  get 'posts/*categories_uri/:post_uri' => "posts#show"
  get 'categories/*categories_uri' => "categories#show"
  # here is the regular page route
  get 'page/:uri' => "pages#show", as: :page
  get 'sitemap/*categories_uri' => 'sitemap#show'
  get 'sitemap' => 'sitemap#index'
  ## Catch all unexisted routes
  match "*path", to: "application#render_404", via: :all
end

以下是我如何构建要在视图中编辑的链接:

= link_to "Edit", "/editor" + page_path(item)

在路线上host/page/:slug我可以看到该页面,但是当我在路线上时host/edit/page/:slug我有 404 错误。


在浏览器控制台中,我可以看到错误: GET http://host/page/:slug?mercury_frame=true&_=1388132782182 404 (Not Found)但是所有汞编辑器的js文件都已加载。

尝试在视图中使用此代码

<%= link_to "Edit",  "/editor" + admin_page_path(item), id: "edit_link", data: { save_url: mercury_update_admin_page_path(item) } %>

并将此代码放在水银的末尾.js

onload: function() {
//Mercury.PageEditor.prototype.iframeSrc = function(url) { return '/testing'; }
Mercury.on('ready', function() {
  var link = $('#mercury_iframe').contents().find('#edit_link');
  Mercury.saveUrl = link.data('save_url');
  link.hide();
});
Mercury.on('saved', function() {
  window.location.href = window.location.href.replace(//editor//i, '/');
});

}

然后导航到http://host/editor/admin/pages/:slug

最新更新