My 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
Here is how I construct link to edit in view:
= link_to "Edit", "/editor" + page_path(item)
On the route host/page/:slug
I can see the page, but when Im on route host/edit/page/:slug
I have 404 error.
In the browser console I can see error: GET http://host/page/:slug?mercury_frame=true&_=1388132782182 404 (Not Found)
But all mercury-editor's js files have been loaded.
Try to use this code in the view
<%= link_to "Edit", "/editor" + admin_page_path(item), id: "edit_link", data: { save_url: mercury_update_admin_page_path(item) } %>
And place this code to the end of mercury.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, '/');
});
}
Then navigate to http://host/editor/admin/pages/:slug
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.