make profile button on photo show page. (removed clean hash on usercontroller)

This commit is contained in:
danielvincent 2010-10-20 12:19:06 -07:00
parent 98a8fbcfb6
commit 61122b83d0
5 changed files with 45 additions and 18 deletions

View file

@ -36,10 +36,8 @@ class UsersController < ApplicationController
flash[:error] = "Password Change Failed"
end
else
data = clean_hash params[:user]
prep_image_url(data)
if @user.update_profile data
prep_image_url(params[:user])
if @user.update_profile params[:user][:profile]
flash[:notice] = "Profile updated"
else
flash[:error] = "Failed to update profile"
@ -120,15 +118,4 @@ class UsersController < ApplicationController
end
end
def clean_hash(params)
return {
:profile =>
{
:first_name => params[:profile][:first_name],
:last_name => params[:profile][:last_name],
:image_url => params[:profile][:image_url]
}
}
end
end

View file

@ -281,7 +281,7 @@ class User
########### Profile ######################
def update_profile(params)
if self.person.update_attributes(params)
if self.person.profile.update_attributes(params)
push_to_aspects profile, :all
true
else

View file

@ -76,7 +76,10 @@
%div{:id => @photo.id}
#show_photo
= linked_scaled_photo @photo, @album
.edit_pane
.controls{:data=>{:actor=>"#{@photo.person.owner.id}",:image_url=>"#{@photo.url(:thumb_medium)}"}}
= link_to 'make profile photo', '#', :class => "make_profile_photo"
= linked_scaled_photo @photo, @album
.caption
-if current_user.owns? @photo
-if @photo.caption and @photo.caption != ""

View file

@ -67,7 +67,6 @@ $(document).ready(function(){
};
});
});//end document ready
@ -105,3 +104,15 @@ function openVideo(type, videoid, link) {
$(container).slideDown('fast', function() { });
link.onclick = function() { $(container).slideToggle('fast', function() { } ); }
}
$(".make_profile_photo").live("click", function(){
var user_id = $(this).closest(".controls").attr('data-actor');
photo_url = $(this).closest(".controls").attr('data-image_url');
$.ajax({
type: "PUT",
url: '/users/'+user_id,
data: {"user":{"profile":{ "image_url": photo_url }}},
success: window.location.reload()
});
});

View file

@ -1089,3 +1089,29 @@ header
img
:height 27px
:width 27px
.edit_pane
:display inline
:position relative
.controls
:display none
:background
:color rgba(51,51,51,0.9)
:padding 10px
:position absolute
:right 0
a
:font
:weight bold
:color #eee
:text-shadow 0 1px #000
&:hover
:color #fff
&:hover
.controls
:display inline