English 中文(简体)
铁路/铁路/铁路
原标题:rails skip_before_filter :verify_authenticity_token not working

我需要从一个办公室电脑上通过一个垃圾箱把一个服务器上岗。 我的发言

skip_before_filter :verify_authenticity_token

在控制人员中,我每次都试图“你想要的改变遭到拒绝”,在我看一看一看记录时,我就开始。

ActionController::InvalidAuthenticityToken

Am I misunderstanding something? Here is the code from the ruby script

   url="display_ad[title]=#{row[1]}"
   date_arr = row[2].split( / )
   start_date = date_arr[2].to_s + "-" + date_arr[0].to_s + "-" + date_arr[1].to_s
   url+="&display_ad[start_date]=#{start_date}"

   date_arr = row[3].split( / )
   end_date = Date.new( date_arr[2].to_i,  date_arr[0].to_i,  date_arr[1].to_i )
   end_date = end_date + 7
   end_date = end_date.strftime("%Y-%m-%d")
   url+="&display_ad[end_date]=#{end_date}"
   url+="&display_ad[slug]=#{row[7]}"
   url+="&display_ad[category]=othr"
   url = url.gsub("
","")
   url = url.gsub("
","")
   p url
   easy =  Curl::Easy.http_post("http://example.com/advertising/web/web_service_add", url)

以及控制者的行动

 ad = DisplayAds.new(params[:display_ad])
 ad.save
问题回答

我在与铁路项目2.3.8相同的问题之后,就坐在这个网页上。 页: 1 在若干控制人员中,核实“真实性——象征性的,但这是我第一次尝试在<代码>ApplicationController上使用该编码,该类别涉及申请控制人界定的行动。

我把我的行动转移到另一个控制员身上,同时把天空_放在“过滤线”之前,核查工作按照预期是正确的。 我认为,也许问题在于,在申请控制人直接用于该类确定的行动时,这并不像你所期望的那样奏效。 我没有调查为什么可能发生这种情况,因为我很抱歉,我所努力的具体行动已经在那里界定,因此,这是一条更好的选择。 遇到这一问题的其他人应设法将其受到影响的行动从<代码>ApplicationController类别移出。

有趣的是,在铁路项目3.2.1中,I使用了skip_ before_filter :verification_authenticity_token <>code> in the ApplicationController<>/code>,其行动在该类别中界定,并进行了罚款。

请检查您的编码,看看这一行:

protect_from_forgery

It will start the csrf protection. Keep in mind that put all your sckip_before_filter alike after this method.

Gook Luck!





相关问题
rails collection_select vs. select

collection_select and select Rails helpers: Which one should I use? I can t see a difference in both ways. Both helpers take a collection and generates options tags inside a select tag. Is there a ...

SSL slowness in EC2

We ve deployed our rails app to EC2. In our setup, we have two proxies on small instances behind round-robin DNS. These run nginx load balancers for a dynamically growing and shrinking farm of web ...

Auth-code with A-Za-z0-9 to use in an URL parameter

As part of a web application I need an auth-code to pass as a URL parameter. I am currently using (in Rails) : Digest::SHA1.hexdigest((object_id + rand(255)).to_s) Which provides long strings like : ...

RubyCAS-Client question: Rails

I ve installed RubyCAS-Client version 2.1.0 as a plugin within a rails app. It s working, but I d like to remove the ?ticket= in the url. Is this possible?

activerecord has_many :through find with one sql call

I have a these 3 models: class User < ActiveRecord::Base has_many :permissions, :dependent => :destroy has_many :roles, :through => :permissions end class Permission < ActiveRecord::...

Ordering a hash to xml: Rails

I m building an xml document from a hash. The xml attributes need to be in order. How can this be accomplished? hash.to_xml

Text Editor for Ruby-on-Rails

guys which text editor is good for Rubyonrails? i m using Windows and i was using E-Texteditor but its not free n its expired now can anyone plese tell me any free texteditor? n which one is best an ...

How to get SQL queries for each user where env is production

I’m developing an application dedicated to generate statistical reports, I would like that user after saving their stat report they save sql queries too. To do that I wrote the following module: ...