Permalink
Browse files

added pseudo_cursors for bulk activerecord updates

  • Loading branch information...
1 parent 82a844a commit 387821a15f7acdae2dfafdfbd48896547aa13883 activefx committed Sep 15, 2008
View
@@ -31,3 +31,6 @@
[submodule "vendor/plugins/footnotes"]
path = vendor/plugins/footnotes
url = git://github.com/drnic/rails-footnotes.git
+[submodule "vendor/plugins/pseudo_cursors"]
+ path = vendor/plugins/pseudo_cursors
+ url = git://github.com/sml/pseudo_cursors.git
@@ -9,12 +9,13 @@ def index
# Add invitations to all users
def create
- if User.add_to_invitation_limit(params[:add_invites].to_i)
+ if !params[:add_invites].blank?
+ User.add_to_invitation_limit(params[:add_invites].to_i)
flash[:notice] = "Invitation limit updated."
redirect_to admin_users_path
else
- flash.now[:error] = "There was a problem updating the invitation limit."
- render :action => 'index'
+ flash[:error] = "There was a problem updating the invitation limit."
+ redirect_to admin_invites_path
end
end
@@ -49,4 +49,10 @@ def if_invites_available?
yield if in_beta? and logged_in? and (current_user.invitation_limit > 0)
end
+ def focus_on_div(div)
+ update_page do |page|
+ page[div].focus
+ end
+ end
+
end
@@ -1,4 +1,4 @@
-<h1>Users waiting to sign up (<%=h @users.total_entries %>)</h1>
+<h1>Users waiting to sign up (<%=h @users.total_entries rescue nil%>)</h1>
<p><%= link_to 'User Administration', admin_users_path %> |
<%= link_to 'Manage Beta Invitations for All Users', admin_invites_path %></p>
@@ -10,10 +10,14 @@ Send invitations to users who have signed up on the front page for the private b
<% end -%>
</p>
+<% if @users -%>
+
<ul>
<% for user in @users -%>
<li><%=h user.email %></li>
<% end -%>
</ul>
<%= will_paginate @users %>
+
+<% end -%>
@@ -4,5 +4,8 @@ else
page['logins'].hide
page['logins'].replace_html :partial => "shared/login_with_openid"
page['logins'].appear
+ page.delay(1) do
+ page << focus_on_div("openid_identifier")
+ end
end
@@ -19,3 +19,4 @@
<p><%= submit_tag 'Log in', :disable_with => "Signing in&hellip;" %></p>
<% end -%>
+
@@ -4,5 +4,9 @@ else
page['logins'].hide
page['logins'].replace_html :partial => "shared/login"
page['logins'].appear
+ page.delay(1) do
+ page << focus_on_div("login")
+ end
end
+
@@ -105,17 +105,17 @@ def find_for_forget(email)
(u.forgot_password && u.save) ? true : false
end
+ # find_each method from pseudo_cursors
def add_to_invitation_limit(number)
- users = find :all, :conditions => ['enabled = ? and activated_at IS NOT NULL', true]
- users.each do |u|
+ find_each(:conditions => ['enabled = ? and activated_at IS NOT NULL', true]) do |u|
u.add_invites(number)
u.save(false)
end
end
+ # find_each method from pseudo_cursors
def remove_all_invitations
- users = find :all
- users.each do |u|
+ find_each do |u|
u.invitation_limit = 0
u.save(false)
end
@@ -1,2 +1,3 @@
// Place your application-specific JavaScript functions and classes here
// This file is automatically included by javascript_include_tag :defaults
+
Submodule pseudo_cursors added at 239b0c

0 comments on commit 387821a

Please sign in to comment.