Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Rails sms_fu error

brendan lims instructions for setting up the sms_fu gem say run either

sms_fu = SMSFu::Client.configure(:delivery => :action_mailer)

or

sms_fu = SMSFu::Client.configure(:delivery => :pony, :pony_config => { :via => :sendmail })

or

PONY_CONFIG = { 
 :via => :smtp, 
 :via_options => {
 :address              => 'smtp.gmail.com',
 :port                 => '587',
 :user_name            => 'username',
 :password             => 'password',
 :authentication       => :plain, 
 :enable_starttls_auto => true,
 :domain               => "localhost.localdomain"
}}
sms_fu = SMSFu::Client.configure(:delivery => :pony, :pony_config => PONY_CONFIG)

I tried the first (assuming actionmailer is set up by default, maybe thats wrong). Then the second (after installing pony and mailing something to be sure it works, which was fine) and the last. No errors show in anthing above. The instructions say after this set up, a command like this is supposed to work

sms_fu.deliver("5558675309","at&t","message")

In all set ups i get this error

NameError: uninitialized constant RAILS_ROOT
from /Users/name/.rvm/gems/ruby-1.9.2-p290@rails3tutorial/gems/sms_fu-1.1.2/lib/sms_fu/sms_fu.rb:102:in `template_directory'
from /Users/name/.rvm/gems/ruby-1.9.2-p290@rails3tutorial/gems/sms_fu-1.1.2/lib/sms_fu/sms_fu.rb:55:in `config_yaml'
from /Users/name/.rvm/gems/ruby-1.9.2-p290@rails3tutorial/gems/sms_fu-1.1.2/lib/sms_fu/sms_fu.rb:65:in `from_address'
from /Users/name/.rvm/gems/ruby-1.9.2-p290@rails3tutorial/gems/sms_fu-1.1.2/lib/sms_fu/sms_fu.rb:41:in `deliver'
from (irb):28
from /Users/name/.rvm/gems/ruby-1.9.2-p290@rails3tutorial/gems/railties-3.1.0/lib/rails/commands/console.rb:45:in `start'
from /Users/name/.rvm/gems/ruby-1.9.2-p290@rails3tutorial/gems/railties-3.1.0/lib/rails/commands/console.rb:8:in `start'
from /Users/name/.rvm/gems/ruby-1.9.2-p290@rails3tutorial/gems/railties-3.1.0/lib/rails/commands.rb:40:in `<top (required)>'
from script/rails:6:in `require'
from script/rails:6:in `<main>'

How do i solve this.

P.S.

Im on rails 3

  • Edit

Now i get, after changing RAILS_ROOT to Rails.root in line 102 of lib/sms_fu/sms_fu.rb (according to Dogbert's answer)

Psych::SyntaxError: couldn't parse YAML at line 7 column 11
from /Users/name/.rvm/rubies/ruby-1.9.2-p290/lib/ruby/1.9.1/psych.rb:148:in `parse'
from /Users/name/.rvm/rubies/ruby-1.9.2-p290/lib/ruby/1.9.1/psych.rb:148:in `parse_stream'
from /Users/name/.rvm/rubies/ruby-1.9.2-p290/lib/ruby/1.9.1/psych.rb:119:in `parse'
from /Users/name/.rvm/rubies/ruby-1.9.2-p290/lib/ruby/1.9.1/psych.rb:106:in `load'
from /Users/name/.rvm/gems/ruby-1.9.2-p290@rails3tutorial/gems/sms_fu-1.1.2/lib/sms_fu/sms_fu.rb:55:in `config_yaml'
from /Users/name/.rvm/gems/ruby-1.9.2-p290@rails3tutorial/gems/sms_fu-1.1.2/lib/sms_fu/sms_fu.rb:65:in `from_address'
from /Users/name/.rvm/gems/ruby-1.9.2-p290@rails3tutorial/gems/sms_fu-1.1.2/lib/sms_fu/sms_fu.rb:41:in `deliver'
from (irb):6
from /Users/name/.rvm/gems/ruby-1.9.2-p290@rails3tutorial/gems/railties-3.1.0/lib/rails/commands/console.rb:45:in `start'
from /Users/name/.rvm/gems/ruby-1.9.2-p290@rails3tutorial/gems/railties-3.1.0/lib/rails/commands/console.rb:8:in `start'
from /Users/name/.rvm/gems/ruby-1.9.2-p290@rails3tutorial/gems/railties-3.1.0/lib/rails/commands.rb:40:in `<top (required)>'
from script/rails:6:in `require'
from script/rails:6:in `<main>'

my sms_fu.yml looks like

config:
  from_address: [email protected]

carriers:
 alltel:
  name: Alltel
  value: @message.alltel.com
 ameritech:
  name: Ameritech
  value: @paging.acswireless.com
 at&t: 
  name: AT&T
  value: @txt.att.net
 bell-atlantic: 
  name: Bell Atlantic
  value: @message.bam.com
 bellsouthmobility:
  name: Bellsouth Mobility
  value: @blsdcs.net
 blueskyfrog: 
  name: BlueSkyFrog
  value: @blueskyfrog.com
 boost: 
  name: Boost Mobile
  value: @myboostmobile.com
 cellularsouth: 
  name: Cellular South
  value: @csouth1.com
 comcast: 
  name: Comcast PCS
  value: @comcastpcs.textmsg.com
 cricket: 
  name: Cricket
  value: @sms.mycricket.com
 kajeet: 
  name: kajeet
  value: @mobile.kajeet.net
 metropcs: 
  name: Metro PCS
  value: @mymetropcs.com
 nextel:
  name: Nextel
  value: @messaging.nextel.com
 powertel: 
  name: Powertel
  value: @ptel.net
 pscwireless: 
  name: PSC Wireless
  value: @sms.pscel.com
 qwest: 
  name: Qwest
  value: @qwestmp.com
 southernlink: 
  name: Southern Link
  value: @page.southernlinc.com
 sprint: 
  name: Sprint PCS
  value: @messaging.sprintpcs.com
 suncom: 
  name: Suncom
  value: @tms.suncom.com
 t-mobile: 
  name: T-Mobile
  value: @tmomail.net
 tracfone: 
  name: Tracfone
  value: @mmst5.tracfone.com
 telus-mobility: 
  name: Telus Mobility
  value: @msg.telus.com
 virgin: 
  name: Virgin Mobile
  value: @vmobl.net
 verizon: 
  name: Verizon Wireless
  value: @vtext.com
 # International Carriers
 aliant-canada:
  name: Aliant (Canada)
  value: @chat.wirefree.ca
 beeline-ua: 
  name: Beeline
  value: @sms.beeline.ua
 bellmobility-canada:
  name: Bell Mobility (Canada)
  value: @txt.bell.ca
 bpl-mobile: 
  name: BPL Mobile
  value: @bplmobile.com
 claro-brazil:
  name: Claro (Brazil)
  value: @clarotorpedo.com.br
 claro-nicaragua: 
  name: Claro (Nicaragua)
  value: @ideasclaro-ca.com
 du-arab-emirates: 
  name: Du (UAE)
  value: @email2sms.ae
 e-plus-germany: 
  name: E-Plus (Germany)
  value: @smsmail.eplus.de
 etisalat-arab-emirates: 
  name: Etisalat (UAE)
  value: @email2sms.ae
 fido-canada: 
  name: Fido
  value: @fido.ca
 manitobatelecom-canada:
  name: Manitoba Telecom (Canada)
  value: @text.mtsmobility.com
 mobinil-egypt:
  name: Mobinil
  value: @mobinil.net
 mobistar-belgium: 
  name: Mobistar (Belgium)
  value: @mobistar.be
 mobitel: 
  name: Mobitel
  value: @sms.mobitel.lk
 movistar-spain: 
  name: Movistar (Spain)
  value: @correo.movistar.net
 northerntel-canada:
  name: NorthernTel (Canada)
  value: @txt.northerntelmobility.com
 o2-germany: 
  name: o2 (Germany)
  value: @o2online.de
 o2-uk: 
  name: o2 (UK)
  value: @mmail.co.uk
 orange-mumbai: 
  name: Orange (Mumbai)
  value: @orangemail.co.in
 orange-netherlands: 
  name: Orange (Netherlands)
  value: @sms.orange.nl
 orange-uk: 
  name: Orange (UK)
  value: @orange.net
 rogers-wireless: 
  name: Rogers Wireless
  value: @pcs.rogers.com
 rogers-canada:
  name: Rogers (Canada)
  value: @pcs.rogers.ca
 sasktel-canada:
  name: SaskTel (canada)
  value: @sms.sasktel.ca
 sfr-france: 
  name: SFR (France)
  value: @sfr.fr
 t-mobile-austria: 
  name: T-Mobile (Austria)
  value: @sms.t-mobile.at
 t-mobile-germany: 
  name: T-Mobile (Germany)
  value: @t-d1-sms.de
 t-mobile-germany: 
  name: T-Mobile (Netherlands)
  value: @gin.nl
 t-mobile-uk: 
  name: T-Mobile (UK)
  value: @t-mobile.uk.net
 telebec-canada:
  name: Telebec (Canada)
  value: @txt.telebecmobilite.com
 telefonica-spain: 
  name: Telefonica (Spain)
  value: @movistar.net
 telus-canada:
  name: Telus (Canada)
  value: @msg.telus.com
 virgin-canada:
  name: Virgin (Canada)
  value: @vmobile.ca 
 vodafone-germany: 
  name: Vodafone (Germany)
  value: @vodafone-sms.de
 vodafone-egypt: 
  name: Vodafone (Egypt)
  value: @vodafone.com.eg
 vodafone-uk: 
  name: Vodafone (UK)
  value: @sms.vodafone.net
 vodafone-italy: 
  name: Vodafone (Italy)
  value: @sms.vodafone.it
 vodafone-jp-chuugoku: 
  name: Vodafone (Japan - Chuugoku)
  value: @n.vodafone.ne.jp
 vodafone-jp-hokkaido: 
  name: Vodafone (Japan - Hokkaido)
  value: @d.vodafone.ne.jp
 vodafone-jp-hokuriko: 
  name: Vodafone (Japan - Hokuriko)
  value: @r.vodafone.ne.jp
 vodafone-jp-kansai: 
  name: Vodafone (Japan - Kansai)
  value: @k.vodafone.ne.jp
 vodafone-jp-osaka: 
  name: Vodafone (Japan - Osaka)
  value: @k.vodafone.ne.jp
 vodafone-jp-kanto: 
  name: Vodafone (Japan - Kanto)
  value: @k.vodafone.ne.jp
 vodafone-jp-koushin: 
  name: Vodafone (Japan - Koushin)
  value: @k.vodafone.ne.jp
 vodafone-jp-tokyo: 
  name: Vodafone (Japan - Tokyo)
  value: @k.vodafone.ne.jp
 vodafone-jp-kyuushu: 
  name: Vodafone (Japan - Kyuushu)
  value: @q.vodafone.ne.jp
 vodafone-jp-okinawa: 
  name: Vodafone (Japan - Okinawa)
  value: @q.vodafone.ne.jp
 vodafone-jp-shikoku: 
  name: Vodafone (Japan - Shikoku)
  value: @s.vodafone.ne.jp
 vodafone-jp-touhoku: 
  name: Vodafone (Japan - Touhoku)
  value: @h.vodafone.ne.jp
 vodafone-jp-niigata: 
  name: Vodafone (Japan - Niigata)
  value: @h.vodafone.ne.jp
 vodafone-jp-toukai: 
  name: Vodafone (Japan - Toukai)
  value: @h.vodafone.ne.jp
 vodafone-spain: 
  name: Vodafone (Japan - Spain)
  value: @vodafone.es

read through the comments on the right answer to know the full solution

like image 698
jack Avatar asked Nov 17 '11 18:11

jack


1 Answers

This plugin hasn't been updated for a while. Rails deprecated RAILS_ROOT in favor of Rails.root

You'll need to remove RAILS_ROOT from this file, line 102, and replace with Rails.root

  directory = defined?(Rails) ? "#{RAILS_ROOT}/config" : "#{File.dirname(__FILE__)}/../../templates"

to

  directory = defined?(Rails) ? "#{Rails.root}/config" : "#{File.dirname(__FILE__)}/../../templates"

https://github.com/brendanlim/sms-fu/blob/master/lib/sms_fu/sms_fu.rb#L102

like image 170
Dogbert Avatar answered Sep 30 '22 18:09

Dogbert