summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--app/views/layouts/_messages.html.haml2
-rw-r--r--config/initializers/i18n.rb4
-rw-r--r--config/locales/en.yml6
-rw-r--r--engines/support/app/controllers/tickets_controller.rb13
-rw-r--r--lib/extensions/couchrest.rb3
5 files changed, 20 insertions, 8 deletions
diff --git a/app/views/layouts/_messages.html.haml b/app/views/layouts/_messages.html.haml
index 7ff985f..18be54f 100644
--- a/app/views/layouts/_messages.html.haml
+++ b/app/views/layouts/_messages.html.haml
@@ -1,6 +1,6 @@
#messages
- flash.each do |name, msg|
- if msg.is_a?(String)
- %div{:class => "alert alert-#{name == :notice ? "success" : "error"}"}
+ %div{:class => "alert alert-#{name == :notice ? "success" : name}"}
%a.close{"data-dismiss" => "alert"} ×
= content_tag :div, format_flash(msg), :id => "flash_#{name}"
diff --git a/config/initializers/i18n.rb b/config/initializers/i18n.rb
index c277a22..b209d00 100644
--- a/config/initializers/i18n.rb
+++ b/config/initializers/i18n.rb
@@ -8,3 +8,7 @@ MATCH_LOCALE = /(#{I18n.available_locales.join('|')})/
# I18n.available_locales is always an array of symbols, but for comparison with
# params we need it to be an array of strings.
LOCALES_STRING = I18n.available_locales.map(&:to_s)
+
+# enable using the cascade option
+# see svenfuchs.com/2011/2/11/organizing-translations-with-i18n-cascade-and-i18n-missingtranslations
+I18n::Backend::Simple.send(:include, I18n::Backend::Cascade)
diff --git a/config/locales/en.yml b/config/locales/en.yml
index 899d659..a7a76a8 100644
--- a/config/locales/en.yml
+++ b/config/locales/en.yml
@@ -1,4 +1,10 @@
en:
+ flash:
+ success: "%{resource} was successfully saved."
+ create:
+ success: "%{resource} was successfully created."
+ update:
+ success: "%{resource} was successfully updated."
home: Home
privacy_policy: Privacy Policy
terms_of_service: Terms of Service
diff --git a/engines/support/app/controllers/tickets_controller.rb b/engines/support/app/controllers/tickets_controller.rb
index 99357ab..19663c3 100644
--- a/engines/support/app/controllers/tickets_controller.rb
+++ b/engines/support/app/controllers/tickets_controller.rb
@@ -23,11 +23,8 @@ class TicketsController < ApplicationController
@ticket.comments.last.posted_by = current_user.id
@ticket.comments.last.private = false unless admin?
@ticket.created_by = current_user.id
- if @ticket.save
- flash[:notice] = t(:thing_was_successfully_created, :thing => t(:ticket))
- if !logged_in?
- flash[:notice] += " " + t(:access_ticket_text, :full_url => ticket_url(@ticket.id))
- end
+ if @ticket.save && !logged_in?
+ flash[:success] = t(:access_ticket_text, :full_url => ticket_url(@ticket.id))
end
respond_with(@ticket, :location => auto_ticket_path(@ticket))
end
@@ -62,10 +59,8 @@ class TicketsController < ApplicationController
end
if @ticket.changed? and @ticket.save
- flash[:notice] = t(:changes_saved)
redirect_to_tickets
else
- flash[:error] = @ticket.errors.full_messages.join(". ") if @ticket.changed?
redirect_to auto_ticket_path(@ticket)
end
end
@@ -88,6 +83,10 @@ class TicketsController < ApplicationController
@title = t(:tickets)
end
+ def self.responder
+ Responders::FlashResponder
+ end
+
private
#
diff --git a/lib/extensions/couchrest.rb b/lib/extensions/couchrest.rb
index 95f5d92..0e5051a 100644
--- a/lib/extensions/couchrest.rb
+++ b/lib/extensions/couchrest.rb
@@ -1,5 +1,8 @@
module CouchRest
module Model
+ class Base
+ extend ActiveModel::Naming
+ end
module Designs
class View