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
@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

View file

@ -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

View file

@ -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

View file

@ -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