am trying to refactor an app that I have inherited that was not coded using rails best practices. I am fairly new to rails and I am doing the tutorials and book thing, but I also need to keep making process on the project. -------------------------------------------------------- I have a model that I have refactored: --------------------------------------------------------- models/weboel23.rb class WEBOEL23 < ActiveRecord::Base establish_connection "as400_#{RAILS_ENV}" set_table_name "WEBOEL23" def email @weboe123 = WEBOEL23 WEBOEL23.where(ACT223: act223).first.email end end ------------------------------------- and I am calling it from models/order.rb: if approval1!="" Mailer.deliver_order_distributor_approval_email(@weboel23.email, "Coastal Pet Online Ordering<noreply-GAu+BHpYYJ5t1OO0OYaSVA@public.gmane.org>", "DIST Confirmation-1 ", email_details) end ------------------------------------ the error that it is returning is - NoMethodError (Undefined method 'email' for nil:NilClass): - does this mean that the email record is returning blank? I have tried setting @weboe123 = WEBOEL23 in my def but it is still coming back undefined. Does anyone have any insights or clues that I may be missing?? -------------------------------- I also tried: models/weboel23.rb class WEBOEL23 < ActiveRecord::Base establish_connection "as400_#{RAILS_ENV}" set_table_name "WEBOEL23" def WEBOEL23 @weboe123 = WEBOEL23 end def get_email @WEBOEL23.where(ACT223: act223).first.email end end models/order.rb if approval1!="" Mailer.deliver_order_distributor_approval_email(weboel.get_email, "Coastal Pet Online Ordering<noreply-GAu+BHpYYJ5t1OO0OYaSVA@public.gmane.org>", "DIST Confirmation-1 ", email_details) end ------------------------------------------- executing the code this way results in the error NameError (undefined local variable or method 'weboel' ) ----------------------------------------- thank in advance for any help -- Posted via http://www.ruby-forum.com/. -- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To unsubscribe from this group and stop receiving emails from it, send an email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To view this discussion on the web visit https://groups.google.com/d/msgid/rubyonrails-talk/2fe5c423ca7f10d59c61d36283250080%40ruby-forum.com. For more options, visit https://groups.google.com/groups/opt_out.