infoarts-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org
2006-Nov-20 20:33 UTC
Getting started with ActiveMerchant & new Ecommerce book
Hi there I''ve got a copy of the ''Beginning Ruby on Rails Ecommerce'' book and am trying to integrate ActiveMerchant into my app. My order.rb file has the line: ''include ActiveMerchant::Billing'' per the book. My Order model also has, amongst other things, the following validation: '' validates_inclusion_of :billing_country, :in => Address::COUNTRIES.map {|disp, value| value}'' where the constant COUNTRIES has been defined in my Address model. From the console, if I try and create an Order.new, I get the following error: ''uninitialized constant COUNTRIES'' and reference to the above validation. Any clues on whether I''m actually including ActiveMerchant the correct way and why it is clashing with my Address model? I thought I only needed to ''require ''active_merchant'' in my environment.rb file? All my gateway tests, including the remote ones, pass out of the box, but I just have to integrate into my app. Any clues would be appreciated. --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
Cody Fauser
2006-Nov-30 16:56 UTC
Re: Getting started with ActiveMerchant & new Ecommerce book
If you install ActiveMerchant into vendor/plugins/active_merchant you don''t even have to require it because we include an init.rb file that Rails will load automatically. You problem is that there is in fact an Address class in ActiveMerchant::Billing that is conflicting with your Address class. The solution to this is just to not include ActiveMerchant:Billing, but to include ActiveMerchant. Then just prefix the ActiveMerchant classes with Billing: Billing::CreditCard.new Or don''t include anything and do: ActiveMerchant::Billing::CreditCard.new Cody On 11/20/06, infoarts-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org <infoarts-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> > Hi there > > I''ve got a copy of the ''Beginning Ruby on Rails Ecommerce'' book and am > trying to integrate ActiveMerchant into my app. > > My order.rb file has the line: > > ''include ActiveMerchant::Billing'' > > per the book. > > My Order model also has, amongst other things, the following validation: > > '' validates_inclusion_of :billing_country, :in => > Address::COUNTRIES.map {|disp, value| value}'' > > where the constant COUNTRIES has been defined in my Address model. > > From the console, if I try and create an Order.new, I get the following error: > > ''uninitialized constant COUNTRIES'' and reference to the above validation. > > Any clues on whether I''m actually including ActiveMerchant the correct > way and why it is clashing with my Address model? > > I thought I only needed to ''require ''active_merchant'' in my environment.rb file? > > All my gateway tests, including the remote ones, pass out of the box, > but I just have to integrate into my app. > > Any clues would be appreciated. > > > >-- Cody Fauser http://www.codyfauser.com http://www.oreilly.com/catalog/rjsrails (RJS Templates for Rails) --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---