Hi, I am trying to figure out why I am receiving the following error. I am following an Apple Developers Rail Application tutorial.>> event.expenses.create(:vendor => vendor1, :amount =>75.00)NameError: undefined local variable or method `vendor1'' for #<Object:0x389a0> from (irb):2 Here is what I have for the models class Event < ActiveRecord::Base validates_presence_of :name validates_numericality_of :budget, :greater_than => 0.0 has_many :expenses has_many :vendors, :through => :expenses end ___________________ class Expense < ActiveRecord::Base belongs_to :event belongs_to :vendor end ___________________ class Vendor < ActiveRecord::Base has_many :expenses has_many :events, :through => :expenses end I read another post where they had issues with Xcode not saving and having to restart terminal. I have done both and everything looks right. Thanks 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 post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
UMQ: Use More Quotes! :vendor => "vendor1", :amount => "75.00" On Jan 28, 9:22 pm, Andrew Reid <rails-mailing-l...-ARtvInVfO7ksV2N9l4h3zg@public.gmane.org> wrote:> Hi, > I am trying to figure out why I am receiving the following error. I am > following an Apple Developers Rail Application tutorial. > > >> event.expenses.create(:vendor => vendor1, :amount =>75.00) > > NameError: undefined local variable or method `vendor1'' for > #<Object:0x389a0> > from (irb):2 > > Here is what I have for the models > > class Event < ActiveRecord::Base > validates_presence_of :name > validates_numericality_of :budget, :greater_than => 0.0 > > has_many :expenses > has_many :vendors, :through => :expenses > end > > ___________________ > > class Expense < ActiveRecord::Base > belongs_to :event > belongs_to :vendor > end > > ___________________ > > class Vendor < ActiveRecord::Base > has_many :expenses > has_many :events, :through => :expenses > end > > I read another post where they had issues with Xcode not saving and > having to restart terminal. I have done both and everything looks > right. > Thanks in advance for any help! > -- > Posted viahttp://www.ruby-forum.com/.--~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe@googlegroups.com For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
Link? The reason is you''re using a temporary variable you haven''t set to any value before you''re using it. You probably want a string ''vendor1'' rather than vendor1 which is a temp variable. Sent from my iPhone On 29/01/2009, at 4:22 PM, Andrew Reid <rails-mailing-list@andreas- s.net> wrote:> > Hi, > I am trying to figure out why I am receiving the following error. I > am > following an Apple Developers Rail Application tutorial. > >>> event.expenses.create(:vendor => vendor1, :amount =>75.00) > NameError: undefined local variable or method `vendor1'' for > #<Object:0x389a0> > from (irb):2 > > > Here is what I have for the models > > > class Event < ActiveRecord::Base > validates_presence_of :name > validates_numericality_of :budget, :greater_than => 0.0 > > has_many :expenses > has_many :vendors, :through => :expenses > end > > > ___________________ > > class Expense < ActiveRecord::Base > belongs_to :event > belongs_to :vendor > end > > ___________________ > > class Vendor < ActiveRecord::Base > has_many :expenses > has_many :events, :through => :expenses > end > > > I read another post where they had issues with Xcode not saving and > having to restart terminal. I have done both and everything looks > right. > Thanks 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 post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---