public
Fork of sudara/alonetone
Description: alonetone - a damn fine musician's home. Upload mp3s, create playlists, track listens, get your widget on. (looking for dev help!)
Homepage: http://alonetone.com
Clone URL: git://github.com/taansen/alonetone.git
give users a serialized user settings
actually make the last_seen_at get updated
log the current ip of each user
TODO: only update ip/last_seen_at minimally
sudara (author)
Mon Mar 17 07:13:49 -0700 2008
commit  13eb00a3ff4df6f146d5144c15d1802b3b7df47d
tree    0551be7a6ff08403e829a40beae2c849a9d039e0
parent  ba24cff3cb1d008199225dd162963081a7006f89
...
28
29
30
31
32
33
34
...
28
29
30
 
31
32
33
0
@@ -28,7 +28,6 @@ class AssetsController < ApplicationController
0
   # GET /assets/1.xml
0
   def show
0
     respond_to do |format|
0
- format.rss
0
       format.html do
0
         @page_title = "#{@asset.title} by #{@user.name} on alonetone"
0
         @assets = [@asset]
...
18
19
20
21
 
22
23
24
...
18
19
20
 
21
22
23
24
0
@@ -18,7 +18,7 @@ class UsersController < ApplicationController
0
     respond_to do |format|
0
       format.html do
0
         @user_count = User.count
0
- @active = User.count(:all, :conditions => "assets_count > 0")
0
+ @active = User.count(:all, :conditions => "assets_count > 0", :include => :pic)
0
       end
0
       format.xml do
0
         @users = User.search(params[:q], :limit => 25)
...
26
27
28
 
 
 
29
30
31
...
47
48
49
50
51
 
 
 
52
53
54
...
140
141
142
143
 
144
145
 
146
147
 
148
149
150
...
189
190
191
192
 
193
194
195
...
26
27
28
29
30
31
32
33
34
...
50
51
52
 
 
53
54
55
56
57
58
...
144
145
146
 
147
148
 
149
150
 
151
152
153
154
...
193
194
195
 
196
197
198
199
0
@@ -26,6 +26,9 @@
0
 require 'digest/sha1'
0
 class User < ActiveRecord::Base
0
   
0
+ # has a bunch of prefs
0
+ serialize :settings
0
+
0
   # Can create music
0
   has_many :assets, :dependent => :destroy, :order => 'created_at DESC'
0
   has_many :playlists, :dependent => :destroy, :order => 'playlists.created_at DESC'
0
@@ -47,8 +50,9 @@ class User < ActiveRecord::Base
0
   # Virtual attribute for the unencrypted password
0
   attr_accessor :password
0
 
0
- # These attributes can be changed by a user
0
- attr_accessible :login, :email, :password, :password_confirmation, :website, :bio, :display_name, :itunes
0
+ # These attributes can be changed via mass assignment
0
+ attr_accessible :login, :email, :password, :password_confirmation, :website, :myspace,
0
+ :bio, :display_name, :itunes, :settings, :city, :state
0
   
0
   # Validations
0
   validates_presence_of :email
0
@@ -140,11 +144,11 @@ class User < ActiveRecord::Base
0
   
0
   def self.paginate_by_params(params)
0
     if params[:all]
0
- self.paginate_all_by_activation_code(nil, :per_page => 24, :order => "created_at DESC", :page => params[:page])
0
+ self.paginate_all_by_activation_code(nil, :per_page => 24, :include => :pic, :order => "users.created_at DESC", :page => params[:page])
0
     elsif params[:playlists]
0
- self.paginate(:all, :conditions => 'users.playlists_count > 0', :per_page => 24, :order => "users.playlists_count DESC", :page => params[:page])
0
+ self.paginate(:all, :conditions => 'users.playlists_count > 0', :per_page => 24, :include => :pic, :order => "users.playlists_count DESC", :page => params[:page])
0
     else
0
- self.paginate(:all, :conditions => 'users.assets_count > 0', :per_page => 24, :order => "users.assets_count DESC", :page => params[:page])
0
+ self.paginate(:all, :conditions => 'users.assets_count > 0', :per_page => 24, :include => :pic, :order => "users.assets_count DESC", :page => params[:page])
0
     end
0
   end
0
   
0
@@ -189,7 +193,7 @@ class User < ActiveRecord::Base
0
   
0
   def to_xml(options = {})
0
     options[:except] ||= []
0
- options[:except] << :email << :token << :token_expires_at << :crypted_password << :identity_url << :fb_user_id << :activation_code << :admin
0
+ options[:except] << :email << :token << :token_expires_at << :crypted_password << :identity_url << :fb_user_id << :activation_code << :admin << :salt
0
     super
0
   end
0
   
...
14
15
16
17
18
19
 
 
 
20
21
22
...
14
15
16
 
 
 
17
18
19
20
21
22
0
@@ -14,9 +14,9 @@ module AuthenticatedSystem
0
     # This is now also used to show which users are online... not at accurate as the
0
     # session based approach, but less code and less overhead.
0
     def update_last_seen_at
0
- return unless logged_in? || session[:sudo]
0
- User.update_all ['last_seen_at = ? AND ip = ?', Time.now.utc, request.env['REMOTE_HOST']], ['id = ?', current_user.id]
0
- current_user.last_seen_at = Time.now.utc
0
+ return unless logged_in?
0
+ current_user.update_attribute(:last_seen_at,Time.now.utc)
0
+ current_user.update_attribute(:ip, request.remote_ip)
0
     end
0
     
0
     def login_required

Comments

    No one has commented yet.