flash messages are now being set.

This commit is contained in:
Daniel Vincent Grippi 2010-09-13 15:44:26 -07:00
parent 0e5ef9e005
commit 26e4e088d7
4 changed files with 43 additions and 21 deletions

View file

@ -30,7 +30,8 @@ class AlbumsController < ApplicationController
def create def create
@album = current_user.post(:album, params[:album]) @album = current_user.post(:album, params[:album])
respond_with @album, :notice => "You've created an album called #{@album.name}." flash[:notice] = "You've created an album called #{@album.name}."
respond_with @album
end end
def new def new
@ -40,7 +41,8 @@ class AlbumsController < ApplicationController
def destroy def destroy
@album = Album.find_by_id params[:id] @album = Album.find_by_id params[:id]
@album.destroy @album.destroy
respond_with :location => albums_url, :notice => "Album #{@album.name} destroyed." flash[:notice] = "Album #{@album.name} deleted."
respond_with :location => albums_url
end end
def show def show
@ -58,7 +60,13 @@ class AlbumsController < ApplicationController
def update def update
@album = Album.find_params_by_id params[:id] @album = Album.find_params_by_id params[:id]
respond_with @album, :notice => "Album #{@album.name} successfully edited." if @album.update_attributes params[:album]
flash[:notice] = "Album #{@album.name} successfully edited."
respond_with @album
else
flash[:error] = "Failed to edit album #{@album.name}."
render :action => :edit
end
end end
end end

View file

@ -30,7 +30,8 @@ class AspectsController < ApplicationController
def create def create
@aspect = current_user.aspect params[:aspect] @aspect = current_user.aspect params[:aspect]
respond_with @aspect, :notice => "Click on the plus on the left side to tell Diaspora who can see your new aspect." flash[:notice] = "Click on the plus on the left side to tell Diaspora who can see your new aspect."
respond_with @aspect
end end
def new def new
@ -40,7 +41,8 @@ class AspectsController < ApplicationController
def destroy def destroy
@aspect = Aspect.find_by_id params[:id] @aspect = Aspect.find_by_id params[:id]
@aspect.destroy @aspect.destroy
respond_with :location => aspects_url, :notice => "You are no longer sharing the aspect called #{@aspect.name}." flash[:notice] = "You are no longer sharing the aspect called #{@aspect.name}."
respond_with :location => aspects_url
end end
def show def show
@ -59,7 +61,8 @@ class AspectsController < ApplicationController
def update def update
@aspect = Aspect.find_by_id(params[:id]) @aspect = Aspect.find_by_id(params[:id])
@aspect.update_attributes(params[:aspect]) @aspect.update_attributes(params[:aspect])
respond_with @aspect, :notice => "Your aspect, #{@aspect.name}, has been successfully edited." flash[:notice] = "Your aspect, #{@aspect.name}, has been successfully edited."
respond_with @aspect
end end
def move_friends def move_friends
@ -81,9 +84,11 @@ class AspectsController < ApplicationController
flash[:error] = "didn't work #{params.inspect}" flash[:error] = "didn't work #{params.inspect}"
end end
if aspect = Aspect.first(:id => params[:to][:to]) if aspect = Aspect.first(:id => params[:to][:to])
respond_with aspect, :notice => "You are now showing your friend a different aspect of yourself." flash[:notice] = "You are now showing your friend a different aspect of yourself."
respond_with aspect
else else
respond_with Person.first(:id => params[:friend_id]), :notice => "You are now showing your friend a different aspect of yourself." flash[:notice] = "You are now showing your friend a different aspect of yourself."
respond_with Person.first(:id => params[:friend_id])
end end
end end
end end

View file

@ -77,6 +77,7 @@ class PhotosController < ApplicationController
def destroy def destroy
@photo = Photo.find_by_id params[:id] @photo = Photo.find_by_id params[:id]
@photo.destroy @photo.destroy
flash[:notice] = "Photo deleted."
respond_with :location => @photo.album respond_with :location => @photo.album
end end
@ -96,8 +97,12 @@ class PhotosController < ApplicationController
def update def update
@photo = Photo.find_by_id params[:id] @photo = Photo.find_by_id params[:id]
@photo.update_attributes params[:photo] if @photo.update_attributes params[:photo]
flash[:notice] = "Photo successfully updated."
respond_with @photo respond_with @photo
else
flash[:error] = "Failed to edit photo."
render :action => :edit
end
end end
end end

View file

@ -35,13 +35,16 @@ class RequestsController < ApplicationController
if params[:accept] if params[:accept]
if params[:aspect_id] if params[:aspect_id]
@friend = current_user.accept_and_respond( params[:id], params[:aspect_id]) @friend = current_user.accept_and_respond( params[:id], params[:aspect_id])
respond_with :location => current_user.aspect_by_id(params[:aspect_id]), :notice => "you are now friends" flash[:notice] = "You are now friends."
respond_with :location => current_user.aspect_by_id(params[:aspect_id])
else else
respond_with :location => requests_url, :error => "please select a aspect!" flash[:error] = "Please select an aspect!"
respond_with :location => requests_url
end end
else else
current_user.ignore_friend_request params[:id] current_user.ignore_friend_request params[:id]
respond_with :location => requests_url, :notice => "Ignored friend request." flash[:notice] = "Ignored friend request."
respond_with :location => requests_url
end end
end end
@ -55,7 +58,8 @@ class RequestsController < ApplicationController
begin begin
rel_hash = relationship_flow(params[:request][:destination_url]) rel_hash = relationship_flow(params[:request][:destination_url])
rescue Exception => e rescue Exception => e
respond_with :location => aspect, :error => "No diaspora seed found with this email!" flash[:error] = "No diaspora seed found with this email!"
respond_with :location => aspect
return return
end end
@ -65,17 +69,17 @@ class RequestsController < ApplicationController
@request = current_user.send_friend_request_to(rel_hash[:friend], aspect) @request = current_user.send_friend_request_to(rel_hash[:friend], aspect)
rescue Exception => e rescue Exception => e
raise e unless e.message.include? "already friends" raise e unless e.message.include? "already friends"
message = "You are already friends with #{params[:request][:destination_url]}!" flash[:notice] = "You are already friends with #{params[:request][:destination_url]}!"
respond_with :location => aspect, :notice => message respond_with :location => aspect
return return
end end
if @request if @request
message = "A friend request was sent to #{@request.destination_url}." flash[:notice] = "A friend request was sent to #{@request.destination_url}."
respond_with :location => aspect, :notice => message respond_with :location => aspect
else else
message = "Something went horribly wrong." flash[:error] = "Something went horribly wrong."
respond_with :location => aspect, :error => message respond_with :location => aspect
end end
end end