diff --git a/README.rdoc b/README.rdoc index c1b12af..d0e4e67 100644 --- a/README.rdoc +++ b/README.rdoc @@ -113,6 +113,10 @@ limitation. Some of these carriers are include, Mobitel, Etisalat, T-Mobile (Ne == View Helpers (Rails) +* Include SMSFuHelper in controller or helper module + + include SMSFuHelper + * Retrieve a collection of all carriers <%= carrier_collection %> diff --git a/lib/sms_fu/sms_fu.rb b/lib/sms_fu/sms_fu.rb index a65f419..d14efc4 100644 --- a/lib/sms_fu/sms_fu.rb +++ b/lib/sms_fu/sms_fu.rb @@ -99,8 +99,11 @@ def valid_number?(number) end def template_directory - directory = defined?(Rails) ? "#{RAILS_ROOT}/config" : "#{File.dirname(__FILE__)}/../../templates" - if (defined?(Rails) && Rails.env == 'test') || (defined?(RAILS_ENV) && RAILS_ENV == 'test)') + rails_root = defined?(Rails) ? Rails.root : (defined?(RAILS_ROOT) ? RAILS_ROOT : nil) + env = defined?(Rails) ? Rails.env : (defined?(RAILS_ENV) ? RAILS_ENV : nil) + + directory = !rails_root.nil? ? "#{rails_root}/config" : "#{File.dirname(__FILE__)}/../../templates" + if env == 'test' "#{File.dirname(__FILE__)}/../../templates" else directory