Tag: 会议

Capybara电子邮件重置会话

我需要在注册Capybara后测试一个特定的智能重定向流程。 假设我的网站上有几个interesting_pages ,我希望在确认注册后将用户重定向到上次访问过的有趣页面 小场景: When I visit the interesting page “42” And I visit a couple uninteresting pages # Note during the visit to other pages, session[:interesting_page] is correctly set to the url of page “42” When I sign up and I confirm via the link in the email # At this point I have […]

使用HTTParty登录RESTful Rails应用程序

我有一个基于Rails 3.2 , Ruby 1.9和Devise 2的干净RESTful JSON API的Web应用程序。 我想编写一个基于HTTParty Web客户端的小脚本,以便经常执行某些操作(使用crontab)。 但是我们如何登录并保持会话打开(会话ID由HTTP HEADER传递,并且可能存储在cookie中)。 我真的没有这方面的经验。

预期收益的`#=>`约定

使用#=>描述预期回报是一种Ruby约定。 我意识到我自己使用# => (带有一些空格或标签)。 这只是一个约定,并没有正式的规范,所以我想问一下Ruby程序员的惯例是什么。 是 #=>唯一正确的方式或首选, # =>是首选,或 两者几乎同样使用? 并且,是否有任何理由排除或更喜欢一种forms?

Rails + Sinatra应用程序共享会话

我还没有找到一个好的答案。 如何才能将我的Rails应用程序和Sinatra应用程序(安装在我的Rails应用程序的config.ru中)成功共享会话? 如果我首先访问我的Sinatra应用程序,然后是Rails应用程序,我得到一个错误,如undefined method sweep for {}:Hash ,大概是因为Rails使用Hash的自定义子类来存储会话信息,而Rack :: Session :: Cookie不会“T。 我的代码到目前为止: config.ru map “/” do run MyRailsApp::Application end map “/sinatra” do use Rack::Session::Cookie, key: “_app_session”, secret: “” run MySinatraApp end 配置/初始化/ session_store.rb MyRailsApp::Application.config.session_store :cookie_store, key: ‘_app_session’ 配置/初始化/ secret_token.rb MyRailsApp::Application.config.secret_token = “” # same as config.ru 我错过了什么?

Sinatra没有坚持使用Chrome重定向会话

Sinatra没有通过重定向Chrome来坚持我的会话。 它正在创建一个全新的会话,我将丢失以前的所有会话数据。 作为一个例子(类似于Sinatra文档 ),我正在做这样的事情: enable :sessions get ‘/foo’ do session[:user_id] = 123 session[:session_id] # “ABC”, for example redirect to(‘/bar’) end get ‘/bar’ do # this is “DEF” when responding to Chrome (wrong), # but “ABC” when responding to Firefox or Safari (right) session[:session_id] # this is nil when responding to Chrome (wrong), # but 123 […]

Sinatra和未设置的会话变量

由于某种原因,我的应用程序中没有设置会话变量。 我正在使用Sinatra 1.2.1。 这是一段代码: module GitWiki class App “utf-8” @user = session[:user] end get “/login/?” do erb :login end post “/login” do user = User.get if user.authenticate(params[:username], params[:password]) session[:user] = params[:username] p session # => {:user=>”root”} else # AZIZ! LIGHT! end redirect ‘/’ end get “/” do p session # => {} redirect “/” + […]

使用Rack :: Session :: Cookie删除当前会话

我觉得我在这里遗漏了一些明显的东西,我希望我发布这个时候有人会因为我失踪的谷歌搜索链接而感到羞耻:-) enable :sessions get ‘/logout’ do # What goes here to kill the session? end

检测设计会话何时到期

我想记录用户的会话何时超时,使用:timeoutable和:timeoutable 。 目前, :timeoutable正在按预期工作,并在指定的不活动时间段后将用户重定向到登录页面,但除此之外,我们还要记录何时发生这种情况以帮助改进我们的超时期限。 (显然除非用户明确注销,否则所有会话都会超时。我们将检查自上次活动以来的时间,以确定它是否是自然超时,或者更可能是因为我们设置的超时时间太短。) 是否有可以挂钩的事件或在SessionController中检测会话超时的另一种方式?