layout 'site'
before_filter :authorize, :only => [:api_details, :api_gpx_files]
- before_filter :authorize_web, :only => [:account, :go_public, :view, :diary, :make_friend, :remove_friend]
- before_filter :require_user, :only => [:set_home, :account, :go_public, :make_friend, :remove_friend]
+ before_filter :authorize_web, :only => [:account, :go_public, :view, :diary, :make_friend, :remove_friend, :upload_image]
+ before_filter :require_user, :only => [:set_home, :account, :go_public, :make_friend, :remove_friend, :upload_image]
filter_parameter_logging :password, :pass_crypt, :pass_crypt_confirmation
end
end
+ def upload_image
+ @user.image = params[:user][:image]
+ @user.save!
+ redirect_to :controller => 'user', :action => 'view', :display_name => @user.display_name
+ end
+
def api_details
render :text => @user.to_xml.to_s, :content_type => "text/xml"
end
before_save :encrypt_password
+ file_column :image, :magick => { :geometry => "100x100>" }
+
def after_initialize
self.creation_time = Time.now if self.creation_time.nil?
end
<h2><%= @title %></h2>
+
+<% if @this_user.image %>
+ <%= image_tag url_for_file_column(@this_user, "image") %>
+<% end %>
+<br />
+
<% if @this_user %>
<% if @user == @this_user %>
<%= link_to 'New diary post', :controller => 'diary_entry', :action => 'new', :display_name => @user.display_name %>
<table>
<tr>
<th align="right">From</th>
- <td><%= link_to @message.sender.display_name, :controller => 'user', :action => 'view', :display_name => @message.sender.display_name %></td>
+ <td>
+ <% if @message.sender.image %>
+ <%= image_tag url_for_file_column(@message.sender, "image") %>
+ <% end %>
+
+<%= link_to @message.sender.display_name, :controller => 'user', :action => 'view', :display_name => @message.sender.display_name %></td>
</tr>
<tr>
<th align="right">Subject</th>
<% end %>
</div>
+<h3>User image</h3>
+<% if @this_user.image %>
+ <%= image_tag url_for_file_column(@this_user, "image") %>
+<% end %>
+<br />
+
+<% if @user and @this_user.id == @user.id %>
+ Upload an image<br />
+ <%= form_tag({:action=>'upload_image'}, :multipart => true)%>
+ <%= file_column_field 'user', 'image' %>
+ <input type="submit" name="Upload" />
+ </form>
+<% end %>
+
+<h3>Description</h3?
<div id="description"><%= simple_format(@this_user.description) %></div>
<% if @this_user.home_lat.nil? or @this_user.home_lon.nil? %>
<% @this_user.friends.each do |friend| %>
<% @friend = User.find_by_id(friend.friend_user_id) %>
<tr>
+ <td class="image">
+ <% if @friend.image %>
+ <%= image_tag url_for_file_column(@friend, "image") %>
+ <% end %>
+ </td>
<td class="username"><%= link_to @friend.display_name, :controller => 'user', :action => 'view', :display_name => @friend.display_name %></td>
<td><% if @friend.home_lon and @friend.home_lat %><%= @this_user.distance(@friend).round %>km away<% end %></td>
<td class="message">(<%= link_to 'send message', :controller => 'message', :action => 'new', :user_id => @friend.id %>)</td>
map.connect '/user/confirm', :controller => 'user', :action => 'confirm'
map.connect '/user/go_public', :controller => 'user', :action => 'go_public'
map.connect '/user/reset_password', :controller => 'user', :action => 'reset_password'
+ map.connect '/user/upload_image', :controller => 'user', :action => 'upload_image'
map.connect '/index.html', :controller => 'site', :action => 'index'
map.connect '/edit.html', :controller => 'site', :action => 'edit'
map.connect '/search.html', :controller => 'way_tag', :action => 'search'
--- /dev/null
+class AddUserImage < ActiveRecord::Migration
+ def self.up
+ add_column 'users', 'image', 'mediumblob'
+ end
+
+ def self.down
+ remove_column 'users', 'image'
+ end
+end