diff options
author | Daniel Vincent Grippi <Dan@SPEEDRACER.local> | 2010-09-14 02:44:26 +0400 |
---|---|---|
committer | Daniel Vincent Grippi <Dan@SPEEDRACER.local> | 2010-09-14 02:44:26 +0400 |
commit | 26e4e088d79bcfffa2f56c10a182a28e8d821aeb (patch) | |
tree | 075dc55e14a80c718921eea8cc06c83360782f04 | |
parent | 0e5ef9e0057b6f11eedfccd5edd699645cd04daa (diff) |
flash messages are now being set.
-rw-r--r-- | app/controllers/albums_controller.rb | 14 | ||||
-rw-r--r-- | app/controllers/aspects_controller.rb | 15 | ||||
-rw-r--r-- | app/controllers/photos_controller.rb | 11 | ||||
-rw-r--r-- | app/controllers/requests_controller.rb | 24 |
4 files changed, 43 insertions, 21 deletions
diff --git a/app/controllers/albums_controller.rb b/app/controllers/albums_controller.rb index 47aa8181f..76de92450 100644 --- a/app/controllers/albums_controller.rb +++ b/app/controllers/albums_controller.rb @@ -30,7 +30,8 @@ class AlbumsController < ApplicationController def create @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 def new @@ -40,7 +41,8 @@ class AlbumsController < ApplicationController def destroy @album = Album.find_by_id params[:id] @album.destroy - respond_with :location => albums_url, :notice => "Album #{@album.name} destroyed." + flash[:notice] = "Album #{@album.name} deleted." + respond_with :location => albums_url end def show @@ -58,7 +60,13 @@ class AlbumsController < ApplicationController def update @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 diff --git a/app/controllers/aspects_controller.rb b/app/controllers/aspects_controller.rb index 8b9f39a4b..7bc9c9584 100644 --- a/app/controllers/aspects_controller.rb +++ b/app/controllers/aspects_controller.rb @@ -30,7 +30,8 @@ class AspectsController < ApplicationController def create @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 def new @@ -40,7 +41,8 @@ class AspectsController < ApplicationController def destroy @aspect = Aspect.find_by_id params[:id] @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 def show @@ -59,7 +61,8 @@ class AspectsController < ApplicationController def update @aspect = Aspect.find_by_id(params[:id]) @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 def move_friends @@ -81,9 +84,11 @@ class AspectsController < ApplicationController flash[:error] = "didn't work #{params.inspect}" end 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 - 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 diff --git a/app/controllers/photos_controller.rb b/app/controllers/photos_controller.rb index 7df4fe55a..7f23882f3 100644 --- a/app/controllers/photos_controller.rb +++ b/app/controllers/photos_controller.rb @@ -77,6 +77,7 @@ class PhotosController < ApplicationController def destroy @photo = Photo.find_by_id params[:id] @photo.destroy + flash[:notice] = "Photo deleted." respond_with :location => @photo.album end @@ -96,8 +97,12 @@ class PhotosController < ApplicationController def update @photo = Photo.find_by_id params[:id] - @photo.update_attributes params[:photo] - - respond_with @photo + if @photo.update_attributes params[:photo] + flash[:notice] = "Photo successfully updated." + respond_with @photo + else + flash[:error] = "Failed to edit photo." + render :action => :edit + end end end diff --git a/app/controllers/requests_controller.rb b/app/controllers/requests_controller.rb index 04cf0e9cd..3f98eefb5 100644 --- a/app/controllers/requests_controller.rb +++ b/app/controllers/requests_controller.rb @@ -35,13 +35,16 @@ class RequestsController < ApplicationController if params[:accept] if 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 - respond_with :location => requests_url, :error => "please select a aspect!" + flash[:error] = "Please select an aspect!" + respond_with :location => requests_url end else 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 @@ -55,7 +58,8 @@ class RequestsController < ApplicationController begin rel_hash = relationship_flow(params[:request][:destination_url]) 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 end @@ -65,17 +69,17 @@ class RequestsController < ApplicationController @request = current_user.send_friend_request_to(rel_hash[:friend], aspect) rescue Exception => e raise e unless e.message.include? "already friends" - message = "You are already friends with #{params[:request][:destination_url]}!" - respond_with :location => aspect, :notice => message + flash[:notice] = "You are already friends with #{params[:request][:destination_url]}!" + respond_with :location => aspect return end if @request - message = "A friend request was sent to #{@request.destination_url}." - respond_with :location => aspect, :notice => message + flash[:notice] = "A friend request was sent to #{@request.destination_url}." + respond_with :location => aspect else - message = "Something went horribly wrong." - respond_with :location => aspect, :error => message + flash[:error] = "Something went horribly wrong." + respond_with :location => aspect end end |