我在Rails路由系统中找不到关键字"mount"的含义.
我已经设置了Mercury以在我的Rails应用程序中使用.它将此行添加到我的routes.rb
配置文件中:
Appname::Application.routes.draw do
mount Mercury::Engine => '/'
Run Code Online (Sandbox Code Playgroud)
什么是mount
关键字是什么意思?
我想用一些Visual Editor改进我的页面,并找到关于Mercury编辑器的这个轨道广播.All Done's,但是当我按下SAVE时,我已经重定向到我的页面而没有任何变化.没有错误,没有警告,只是未保存的格式化.任何人都可以帮助我吗?
一些代码:
# routes:
mount Mercury::Engine => '/'
resources :tasks do
resources :comments
member { post :mercury_update }
end
# My controller:
def mercury_update
task = Task.find(params[:id])
task.title = params[:title][:value]
task.body_task = params[:body_task][:value]
task.save!
render text: ""
end
# In views/layouts/mercury.html.erb
new Mercury.PageEditor(saveUrl, {
saveStyle: 'form', // 'form', or 'json' (default json)
saveMethod: null, // 'PUT', or 'POST', (create, vs. update -- default PUT)
visible: true // boolean - if the interface should start visible or …
Run Code Online (Sandbox Code Playgroud) 如何通过gem 在Mercury的/editor/.*路由上添加身份验证检查mercury-rails
?
我的意思是,我知道你可以:
但是我希望用户被踢出编辑器,因为他/她有一个书签给编辑器但没有登录.
PS:有人可以mercury-editor
为此创建标签吗?否则,搜索水银编辑器几乎是不可能的.
在观看关于Mercury Editor的RailsCast#296后,我试图让编辑器重定向到新创建的资源.
我已经可以使用JS和window.location.href=
.在客户端重定向.但是对于新资源,我不能在客户端"猜测"它的URL.我需要它在服务器响应中.
但是,问题是我没有看到在编辑器中使用服务器响应的可能性.无论控制器呈现什么,Mercury 都会丢弃服务器响应,而不是将其用作我的函数的参数mercury:saved
.
有办法解决这个问题吗?
我不能为我的生活弄清楚为什么这不起作用!
我正在通过有关水银的railscast,我无法显示可编辑区域.
的Gemfile
source 'https://rubygems.org'
gem 'rails', '3.2.13'
gem 'mercury-rails', git: 'https://github.com/jejacks0n/mercury.git'
gem 'sqlite3'
group :assets do
gem 'sass-rails', '~> 3.2.3'
gem 'coffee-rails', '~> 3.2.1'
gem 'uglifier', '>= 1.0.3'
end
gem 'jquery-rails'
Run Code Online (Sandbox Code Playgroud)
路线
MercuryRelational::Application.routes.draw do
mount Mercury::Engine => '/'
root to: "pages#show"
Run Code Online (Sandbox Code Playgroud)
显示页面
<h1>Show Page</h1>
<div id="page_content" class="mercury-region" data-type="editable"><%= raw(@page.content) %></div>
Run Code Online (Sandbox Code Playgroud)
显示页面的网址是
http://localhost:4002/editor
文本周围仍然没有可编辑的蓝框.
然而!虽然"未捕获的TypeError:无法读取未定义的属性'konqueror',但我在javascript终端中收到错误"
请帮忙!
安装Mecury Editor后,当我尝试启动服务器时,我得到以下内容:
in `normalize_conditions!': You should not use the `match` method in your router without specifying an HTTP method. (RuntimeError)
If you want to expose your action to both GET and POST, add `via: [:get, :post]` option.
If you want to expose your action to GET, use `get` in the router:
Instead of: match "controller#action"
Do: get "controller#action"
Run Code Online (Sandbox Code Playgroud)
这是路线文件
Bootcanvise::Application.routes.draw do
Mercury::Engine.routes
resources :newsletters
resources :advertisers
devise_for :users
get "home/index"
# The priority is based upon order of creation: first …
Run Code Online (Sandbox Code Playgroud) 我在我的应用程序中设置了汞.它工作正常,但由于我还是铁杆新手,我无法设置身份验证.这是我在运行后尝试的: rails生成汞:安装:身份验证
看来我可以在lib目录中使用该模块
module Mercury
module Authentication
def can_edit?
true if :authenticate_admin! //(from device)
end
end
end
Run Code Online (Sandbox Code Playgroud)我尝试在视图中使用此方法,但它不起作用.Lib目录应该自动加载,因为该行未在配置文件中注释.
顺便说一句,只是在更新方法上添加了before_filter,我阻止普通用户确认编辑页面.但是如果他们手动修改了Url,他们仍然可以看到编辑器本身.
有什么建议吗?
administration authorization ruby-on-rails helpers mercury-editor