From 7fdd0475ae672086bff09b6dfd319c68b0600005 Mon Sep 17 00:00:00 2001 From: Raphael Date: Tue, 2 Nov 2010 11:26:54 -0700 Subject: [PATCH] robustdj's specs now green --- app/controllers/albums_controller.rb | 9 +++++++-- app/models/user.rb | 15 ++++++++------- 2 files changed, 15 insertions(+), 9 deletions(-) diff --git a/app/controllers/albums_controller.rb b/app/controllers/albums_controller.rb index a74143363..1474b5c0f 100644 --- a/app/controllers/albums_controller.rb +++ b/app/controllers/albums_controller.rb @@ -17,8 +17,13 @@ class AlbumsController < ApplicationController aspect = params[:album][:to] @album = current_user.post(:album, params[:album]) - flash[:notice] = I18n.t 'albums.create.success', :name => @album.name - redirect_to :action => :show, :id => @album.id, :aspect => aspect + if @album.persisted? + flash[:notice] = I18n.t 'albums.create.success', :name => @album.name + redirect_to :action => :show, :id => @album.id, :aspect => aspect + else + flash[:error] = I18n.t 'albums.create.failure' + redirect_to albums_path(:aspect => aspect) + end end def new diff --git a/app/models/user.rb b/app/models/user.rb index bb465e78a..6a028a015 100644 --- a/app/models/user.rb +++ b/app/models/user.rb @@ -146,15 +146,16 @@ class User post = build_post(class_name, options) - post.socket_to_uid(id, :aspect_ids => aspect_ids) if post.respond_to?(:socket_to_uid) - push_to_aspects(post, aspect_ids) - - if options[:public] == true - self.services.each do |service| - self.send("post_to_#{service.provider}".to_sym, service, post.message) + if post.persisted? + post.socket_to_uid(id, :aspect_ids => aspect_ids) if post.respond_to?(:socket_to_uid) + push_to_aspects(post, aspect_ids) + + if options[:public] == true + self.services.each do |service| + self.send("post_to_#{service.provider}".to_sym, service, post.message) + end end end - post end