Skip to content

Commit 0a98094

Browse files
committed
update to latest SuperModel
1 parent 793f2ca commit 0a98094

File tree

17 files changed

+97
-79
lines changed

17 files changed

+97
-79
lines changed

Gemfile.lock

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -15,16 +15,16 @@ GIT
1515

1616
GIT
1717
remote: git://github.com/maccman/supermodel.git
18-
revision: d650d99c432ab1f2156fb714b32bf74ec60d562b
18+
revision: 3599867fe915a209612cf24eb326d04b1355b752
1919
specs:
2020
supermodel (0.1.4)
2121
activemodel (~> 3.0.0)
2222

2323
GIT
2424
remote: git://github.com/thoughtbot/paperclip.git
25-
revision: 9e6afe4ff5b6b07bb1d50a4cb4bdd85feb1c9bbf
25+
revision: ef7233d25700a7e69cebd2334b656fa9ca0ae927
2626
specs:
27-
paperclip (2.3.3)
27+
paperclip (2.3.4)
2828
activerecord
2929
activesupport
3030

@@ -76,7 +76,7 @@ GEM
7676
redis
7777
linecache19 (0.5.11)
7878
ruby_core_source (>= 0.1.4)
79-
mail (2.2.5)
79+
mail (2.2.7)
8080
activesupport (>= 2.3.6)
8181
mime-types
8282
treetop (>= 1.4.5)
@@ -85,15 +85,15 @@ GEM
8585
mysql2 (0.2.4)
8686
polyglot (0.3.1)
8787
rack (1.2.1)
88-
rack-less (1.4.0)
88+
rack-less (1.5.0)
8989
less (>= 1.2.21)
9090
rack (>= 0.4)
9191
rack-mount (0.6.13)
9292
rack (>= 1.0.0)
9393
rack-sprockets (1.0.4)
9494
rack (>= 0.4)
9595
sprockets (>= 1.0.0)
96-
rack-test (0.5.4)
96+
rack-test (0.5.6)
9797
rack (>= 1.0)
9898
rails (3.0.0)
9999
actionmailer (= 3.0.0)
@@ -109,7 +109,7 @@ GEM
109109
rake (>= 0.8.4)
110110
thor (~> 0.14.0)
111111
rake (0.8.7)
112-
redis (2.0.6)
112+
redis (2.0.11)
113113
ruby-debug-base19 (0.11.24)
114114
columnize (>= 0.3.1)
115115
linecache19 (>= 0.5.11)
@@ -125,7 +125,7 @@ GEM
125125
daemons (>= 1.0.9)
126126
eventmachine (>= 0.12.6)
127127
rack (>= 1.0.0)
128-
thor (0.14.0)
128+
thor (0.14.3)
129129
treetop (1.4.8)
130130
polyglot (>= 0.3.1)
131131
tzinfo (0.3.23)

README.markdown

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
1-
# Intro
1+
=======
2+
#Intro
23

3-
Holla is a group chat app. The UI is built in a RIA fashion - i.e. is totally asynchronous and super fast.
4-
I've open sourced it for a book I'm writing on building Rich Internet Applications with JavaScript.
4+
Holla is a group chat app. The UI is built in a RIA fashion - i.e. is totally asynchronous and super fast. I've open sourced it for a book I'm writing on building Rich Internet Applications with JavaScript.
55

66
Try it out in your browser (Chrome optimized) - [http://getholla.com](http://getholla.com)
77

app/controllers/users_controller.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ def update
5555

5656
def avatar
5757
@user = User.find(params[:id])
58-
redirect_to @user.avatar.url(:thumb)
58+
redirect_to @user.gravatar_url
5959
end
6060

6161
private

app/models/activity.rb

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,8 +20,7 @@ def for_user(user)
2020
include SuperModel::Creator
2121
belongs_to :user
2222

23-
serialize :data, :seen, :level
24-
indexes :user_id
23+
indexes :user_id
2524

2625
validates_presence_of :klass, :user_id, :creator_id
2726

app/models/asset.rb

Lines changed: 0 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
require "paperclip/storage/happening"
2-
31
class Asset < ActiveRecord::Base
42
include ActiveRecord::Creator
53
include ActiveRecord::RandomID
@@ -26,15 +24,4 @@ class Asset < ActiveRecord::Base
2624
:whiny => true
2725

2826
before_data_post_process Proc.new {|d| d.uploaded = true }
29-
30-
has_attached_file :preview,
31-
:storage => :s3,
32-
:s3_credentials => {
33-
:access_key_id => AppConfig.aws[:access_key_id],
34-
:secret_access_key => AppConfig.aws[:secret_access_key]
35-
},
36-
:s3_permissions => "private",
37-
:path => ":attachment/:id/:style.:extension",
38-
:bucket => AppConfig.aws[:bucket],
39-
:whiny => true
4027
end

app/models/channel.rb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,11 +7,11 @@ class Channel < ActiveRecord::Base
77
has_many :users, :through => :user_channels
88

99
after_create :set_user_channels
10+
11+
validates_presence_of :name
1012

1113
attr_accessible :id, :name
1214

13-
validates_presence_of :name
14-
1515
def channel_activity
1616
ChannelActivity.for_channel(self)
1717
end

app/models/channel_activity.rb

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,6 @@ class ChannelActivity < SuperModel::Base
1313

1414
belongs_to :channel
1515

16-
serialize :data
17-
1816
validates_presence_of :klass, :channel_id, :creator_id
1917

2018
before_create :set_creator_name

app/models/roster.rb

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@ class Roster < SuperModel::Base
33
include SuperModel::Timestamp::Model
44

55
attributes :count
6-
serialize :count
76

87
belongs_to :user
98
validates_presence_of :user_id
@@ -63,9 +62,7 @@ def observer_clients
6362

6463
delegate :name, :to => :user, :prefix => true
6564

66-
def serializable_hash(options = nil)
67-
options ||= {}
68-
options[:methods] = :user_name
69-
super(options)
65+
serialize_options do
66+
methods :user_name
7067
end
7168
end

app/models/user.rb

Lines changed: 8 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -19,20 +19,6 @@ def channel_activity
1919

2020
acts_as_authentic
2121

22-
has_attached_file :avatar,
23-
:styles => {
24-
:thumb => ["48x48#", :png]
25-
},
26-
:storage => :s3,
27-
:s3_credentials => {
28-
:access_key_id => AppConfig.aws[:access_key_id],
29-
:secret_access_key => AppConfig.aws[:secret_access_key]
30-
},
31-
:default_url => "/images/missing.png",
32-
:path => ":attachment/:id/:style.:extension",
33-
:bucket => AppConfig.aws[:bucket],
34-
:whiny => true
35-
3622
def channel_activity
3723
channels.channel_activity
3824
end
@@ -50,15 +36,13 @@ def name
5036
[first_name, last_name].join(" ")
5137
end
5238

53-
def serializable_hash(options = nil)
54-
options ||= {}
55-
options[:only] ||= []
56-
options[:only] += [
57-
:first_name,
58-
:last_name,
59-
:email,
60-
:id
61-
]
62-
super(options)
39+
def gravatar_url
40+
"http://gravatar.com/avatar/" +
41+
"#{Digest::MD5.new.update(email.downcase)}"
42+
end
43+
44+
serialize_options do
45+
only :id, :email
46+
only :first_name, :last_name
6347
end
6448
end

app/views/users/edit.html.erb

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
Your Account
77
<%- end -%>
88

9-
<%= form_for @user, :html => { :multipart => true, :class => "piece" } do |f| %>
9+
<%= form_for @user, :html => { :class => "piece" } do |f| %>
1010
<%= f.error_messages :header_message => false, :message => false %>
1111

1212
<%= hidden_field_tag :user_credentials, params[:user_credentials] %>
@@ -35,13 +35,7 @@
3535
<span>Password again:</span>
3636
<%= f.password_field :password_confirmation, :autocomplete => "off" %>
3737
</label>
38-
39-
<label>
40-
<span>Avatar:</span>
41-
<%= f.file_field :avatar %>
42-
<%= image_tag @user.avatar.url(:thumb), :class => "avatar" %>
43-
</label>
44-
38+
4539
<footer>
4640
<button class="right">Save</button>
4741
</footer>

0 commit comments

Comments
 (0)