<li>
<%= link_to 'Logout',:controller => :account,:action=>:logout,:method=>:post %>
</li>
提交logout的时候,总是卡着不动。
controller里去掉request.post之后,就可以。
但是request.post本身没有错。于是乎猜想是link_to的方法用错了,导致不是用post方法提交的。
进一步追查原因
状态栏显示:logout?method=post
html源码。
<a href="/account/logout?method=post">Logout</a>
看来应该是link_to用错了!
查了之前的用法,然后加了一个大括号!
<li>
<%= link_to 'Logout',{:controller => :account,:action=>:logout},:method=>:post %>
</li>
状态栏显示:logout
html源码
f.method = 'POST';
ok通过了。
查看api
link_to(*args, &block)
Creates a link tag of the given name using a URL created by the set of options. See the valid options in the documentation for url_for. It‘s also possible to pass a string instead of an options hash to get a link tag that uses the value of the string as the href for the link, or use :back to link to the referrer - a JavaScript back link will be used in place of a referrer if none exists. If nil is passed as a name, the link itself will become the name.
Signatures
link_to(name, options = {}, html_options = nil)
link_to(options = {}, html_options = nil) do
# name
end
关键点在这里,
link_to(name, options = {}, html_options = nil)
link_to的第只有三个参数,如果省略{}之后,最后的:method=>:post没有作为post方法提交到后台,而是直接作为参数传递到后台。
分享到:
相关推荐
一个简单的gem,可以使用标准的Rails link_to helper在链接上实现活动状态。 这对导航列表或按钮有帮助,当当前URL匹配链接帮助器上的条件时,为他们提供一个类。 安装 将此行添加到您的应用程序的Gemfile中: gem...
active_link_to 使用一组选项创建的URL创建给定名称的链接标签。 请参阅文档,因为active_link_to基本上是它的包装。 此方法接受可选的:active参数,该参数指示给定链接是否将附加附加CSS类,将该类标记为“活动”...
安装gem install number_to_indian_currency使用捆绑器gem 'number_to_indian_currency'将以下行添加到布局stylesheet_link_tag 'rupees'用法示例number_to_indian_currency(2000) => "Rs.2,000"number_to_indian_...
将您的“ link_to”行切换为“ detour_to”,并将您的控制器“ redirect_to”切换为“ back_or_redirect_to”,以允许用户从其来访者返回。 概要: 在视图中: detour_to controller: :my_models, action: :...
扬帆生成viewhelpers 一个简单(非常简单)的服务,...您可以从中访问助手: date_tag form_tag form_tag_end hidden_field_tag input_field_tag 链接到Submit_link_to link_to_if link_to_unless password_field_
OB-STM32_V754_Change date to to 30-02-02.Hex固件 烧录工具:JLink_Windows_V764c_x86_64.exe 下载之后,进入我的博客主页 查看 “保姆级STM32F103C8T6做USB-TypeC版J-link OB(官方数据手册,硬件设计,固件烧录...
本文档可以解决win10环境中使用ISE14.7的Simulation仿真时总是出错"ERROR:Simulator:861 – Failed to link the design" 解决方法和解决工具都在本文档里面!下载查看。
J-Flash下载STM32用J-link的设置方法
OmniAuth-Rails CSRF保护该gem通过实现直接使用Rails的ActionController::... 只需将所有link_to更改为button_to ,或使用link_to ..., method: :post 。引擎盖下这个gem对您的应用程序有一些作用:
基于move_base的能够循环导航的完成程序包。已经配置好Cmakelists.txt等文件。用法见我的博客。
沁恒仿真器使用说明
TTY ::链接 终端中的超链接 TTY :: Link允许您测试... link_to ( "TTY toolkit" , "https://ttytoolkit.org" ) # => # TTY toolkit 如果终端不支持超链接,则打印替代方法: # TTY toolkit -> https://ttytoolki
使用link()方法: var html = autoLink . link ( text [ , options ] ) ; 例子 var html = autoLink . link ( '<p>Welcom to www.google.com</p>' ) ; //<p>Welcom to <a>www.google.com</a></p> 选项 通过...
nginx链接功能 ... ngx_link_func_lib "/path/to/your/libcfuntest.so" ; ... ... location = /testCFunGreeting { ngx_link_func_call "my_app_simple_get_greeting" ; } } server { listen 8989 ; a
Link to Text Fragment扩展允许通过上下文菜单轻松创建文本片段URL: 选择您要链接到的文本。 右键单击并从上下文菜单中选择“将链接复制到选定的文本”。 如果链接创建成功,则所选文本将以黄色短暂突出显示。 ...
python mediafire-dl.py mediafire_link_1 mediafire_link_2 mediafire_link_3 在 Linux 上添加到 PATH: 1. Open the terminal & Navigate to the folder containing mediafire-dl.py 2. $ sudo cp mediafire-dl...
rootroot@cm-System-Product-Name:/home/wwt/linux_r16$ tar zxvf lichee_parrotv1.1_20161202.tar.gz rootroot@cm-System-Product-Name:/home/wwt/linux_r16$ ...Preparing to unpack .../libencode-locale-perl_...
引入了一个新的Link原语,以传递对路由的独立引用,例如URL,但带有状态( isActive ,...)和方法( transitionTo ,...)。 还带来了随附的模板帮助程序和组件,以便在模板中轻松使用。 ember-link可以路由ember...
快速车把链接 Express JS 应用程序中把手模板的链接。 灵感来自 Ember JS 的车把助手。 安装 npm install --save ... 'link-to' : router . LinkToHelper }
LinkTo转换为其他路线时LinkTo动作。 确定为SEO解决方案。 用法 辛烷 您可以将动作作为LinkTo组件的@invokeAction属性LinkTo : < LinkTo route = ' cart ' xss=removed>Cart</ LinkTo> < LinkTo route = ' cart '...