Tag: devise

如何让我的新注册设计forms为AJAXified?

我想要发生的是,当帐户成功创建时,提交的表单应该消失,并且应该出现一条消息(取决于注册的状态)。 如果成功,他们应该看到一个简单的“谢谢。请检查你的电子邮件。” 如果不是,那么他们应该看到一个合适的消息 – 比如“抱歉,该电子邮件已经被删除”。 这是我的表格: resource_name, :class => “send-with-ajax”, :url => user_registration_path(resource), :validate => true, :html => { :id => ‘user_new’ }) do |f| %> “your-email@address.com”, :input_html => {:autofocus => true}, :validate => true %> “Submit”, :value => “Sign Me Up!” %> 这是我的create.js.erb : $(document).ready(function() { $(‘#user_new’).submit(function() { $(this).fadeOut(600).hide(); $(this).append(‘Thank You. You should receive […]

即使请求头中包含正确的x-csrf-token,也不要在Ajaxpost上设置current_user

使用:Rails 3.0.7设计1.4.5 jquery-rails 1.0.14 通过ajax发布数据时,Devise没有设置current_donor。 我的请求标头如下所示: Host localhost:3000 User-Agent Mozilla/5.0 (Macintosh; Intel Mac OS X 10.6; rv:6.0) Gecko/20100101 Firefox/6.0 Accept */* Accept-Language en-us,en;q=0.5 Accept-Encoding gzip, deflate Accept-Charset ISO-8859-1,utf-8;q=0.7,*;q=0.7 Connection keep-alive Content-Type application/x-www-form-urlencoded; charset=UTF-8 X-Requested-With XMLHttpRequest x-csrf-token UFhqJrlOA1c1sAPeUTtV/ABcq5IeqkfA842ORcIWwks= 在关联的控制器操作中,查看会话值,我发现以下内容: {“_csrf_token”=>”UFhqJrlOA1c1sAPeUTtV/ABcq5IeqkfA842ORcIWwks=”, “warden.user.donor.key”=>[“Donor”, [485], “$2a$10$OtkItrzVhN4Ussnqy5k1Au”], “session_id”=>”e6693e22275385a58e0915538791ea49”} 这将向我表明csrf_token与期望值匹配。 然而,current_donor仍然是零。 我已经阅读了几篇关于此的post,实际上,在开始时,csrf_meta_tag方法不在我的布局中,并且没有设置csrf标记。 但是,现在不再是这种情况了,正在设置csrf令牌,但我仍然没有得到current_donor值。 当我发出ajax get请求时,current_donor正在正确设置。 如果您对我应该看到的其他地方有任何建议,将不胜感激。 最好,汤姆

在.js调用上设置会话立即到期

经过多次反复试验,我已将问题缩小到下面第5行。 出于某种原因,.js响应正在结束用户会话。 使用3.0.4并设计1.1.7(和jQuery 1.5)。 此外,正在更新@organization并在日志中显示Completed 200 OK,因此在尝试下一个操作之前,用户不知道他/她已注销。 非常感谢任何帮助和指导。 *Controller* 1 def make_featured 2 @organization = Organization.find(params[:id]) 3 @organization.is_featured ? @organization.update_attribute(:is_featured,”false”) : @organization.update_attribute(:is_featured,”true”) 4 respond_to do |format| 5 format.js {render :action => “update”, :layout => false} 6 end 7 end 和 *update.js.haml* $(“#organization_” + “#{@organization.id}” ).replaceWith(“#{ escape_javascript(render :partial => ‘users/supplier_view’, :locals => {:organization => @organization}) }”);