summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--app/views/layouts/_messages.html.haml5
-rw-r--r--app/views/layouts/application.html.haml2
-rw-r--r--users/app/controllers/users_controller.rb8
3 files changed, 12 insertions, 3 deletions
diff --git a/app/views/layouts/_messages.html.haml b/app/views/layouts/_messages.html.haml
new file mode 100644
index 0000000..80e34d4
--- /dev/null
+++ b/app/views/layouts/_messages.html.haml
@@ -0,0 +1,5 @@
+- flash.each do |name, msg|
+ - if msg.is_a?(String)
+ %div{:class => "alert alert-#{name == :notice ? "success" : "error"}"}
+ %a.close{"data-dismiss" => "alert"} ×
+ = content_tag :div, msg, :id => "flash_#{name}"
diff --git a/app/views/layouts/application.html.haml b/app/views/layouts/application.html.haml
index a57d65e..e6d22f0 100644
--- a/app/views/layouts/application.html.haml
+++ b/app/views/layouts/application.html.haml
@@ -18,6 +18,6 @@
.content
.row
.span12
- //= render 'layouts/messages'
+ = render 'layouts/messages'
= yield
%footer
diff --git a/users/app/controllers/users_controller.rb b/users/app/controllers/users_controller.rb
index 320ed96..24db13b 100644
--- a/users/app/controllers/users_controller.rb
+++ b/users/app/controllers/users_controller.rb
@@ -22,7 +22,9 @@ class UsersController < ApplicationController
end
def create
- @user = User.create(params[:user])
+ if @user = User.create(params[:user])
+ flash[:notice] = t(:user_created_successfully)
+ end
respond_with @user
end
@@ -30,7 +32,9 @@ class UsersController < ApplicationController
end
def update
- @user.update_attributes(params[:user])
+ if @user.update_attributes(params[:user])
+ flash[:notice] = t(:user_updated_successfully)
+ end
respond_with @user, :location => edit_user_path(@user)
end