Changed from plugin to gem

305 views
Skip to first unread message

kevinf4f

unread,
Mar 15, 2007, 7:55:26 AM3/15/07
to Active Merchant
I installed activemerchant as a rails plugin and soon had it working
with paypal. However due to contraints with my hosting environment I
had to swop to a gems install for production. Now my code no longer
works!

With the activemerchant plugin I had:

environment.rb

require_gem 'money'


payments controller
include ActiveMerchant::Billing::Integrations


Finally in my view (paypal_subscriptions.rhtml ) I used an edited
version of the the code from active merchant:
eg

<% payment_service_for @agency.name, PAYPAL_ACCOUNT,
:currency => 'GBP',
:service => 'paypal',
:html => { :id => 'my-form' } do |service| %>
etc


I have tried variations of require_gem 'activemerchant' in
environment.rb, with no success.

The error is in the view (paypal_subscriptions.rhtml ):


undefined method `payment_service_for' for #<#<Class:0x4660054>:
0x466002c>

Extracted source (around line #1):

1: <% payment_service_for @agency.name, PAYPAL_ACCOUNT,
2: :currency => 'GBP',
3: :service => 'paypal',
4: :html => { :id => 'my-form' } do |service| %>


Any ideas how do I get the view to recognise payment_service_for?

Cody Fauser

unread,
Mar 15, 2007, 10:59:25 PM3/15/07
to activem...@googlegroups.com
Kevin,

Try:

require 'active_merchant'


Cody


--
Cody Fauser
http://shopify.com - e-commerce done right
http://www.codyfauser.com - blog
http://www.oreilly.com/catalog/rjsrails - RJS Templates for Rails

kevinf4f

unread,
Mar 16, 2007, 3:46:27 AM3/16/07
to Active Merchant
Hi Cody

Thanks for your help and suggestion. I added

require 'money'
require 'active_merchant'


to my environment.rb, rebooted the app, same error. I then added the
same code to my controller, same error, and finally (desperation!)
added

<% require 'money' %>
<% require 'active_merchant' %>


to my view.

I still get the "undefined method `payment_service_for' for #<#<Class:
0x4744768>:0x4744740>" error. The fact thaht the server starts up the
app indicates that the gems are being discovered and loaded?

Kevin

On 16 Mar, 02:59, "Cody Fauser" <codyfau...@gmail.com> wrote:
> Kevin,
>
> Try:
>
> require 'active_merchant'
>
> Cody
>

> Cody Fauserhttp://shopify.com- e-commerce done righthttp://www.codyfauser.com- bloghttp://www.oreilly.com/catalog/rjsrails- RJS Templates for Rails- Hide quoted text -
>
> - Show quoted text -

John Ward

unread,
Mar 16, 2007, 5:25:55 AM3/16/07
to activem...@googlegroups.com
Do you have

  include ActiveMerchant::Billing::Integrations

in your controller? I had issues before doing so.

John

kevinf4f wrote:

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "Active Merchant" group.
To post to this group, send email to activem...@googlegroups.com
To unsubscribe from this group, send email to activemerchan...@googlegroups.com
For more options, visit this group at http://groups.google.com/group/activemerchant?hl=en
-~----------~----~----~----~------~----~------~--~---


  

kevinf4f

unread,
Mar 16, 2007, 8:29:29 AM3/16/07
to Active Merchant
I do have ActiveMerchant::Billing::Integrations is in the controller.

I think this is now more of a ruby/rails setup issue, but i would
still appreciate anyones suggestions from this group on resolving the
problem. I am it will be useful to anyone else who may need to swop
from the plugin to using gems.

Cody Fauser

unread,
Mar 16, 2007, 9:37:08 AM3/16/07
to activem...@googlegroups.com
The problem is that as a plugin Rails will automatically run the
init.rb from the plugin, which runs the code:

require 'active_merchant/billing/integrations/action_view_helper'
ActionView::Base.send(:include,
ActiveMerchant::Billing::Integrations::ActionViewHelper)

So in your environment.rb you could try:

require 'money'
require 'active_support'
require 'active_merchant/billing/integrations/action_view_helper'

Then in your application controller you can do:

class ApplicationController < ActionController::Base
include ActiveMerchant::Billing::Integrations::ActionViewHelper
end

Cody Fauser

unread,
Mar 16, 2007, 9:37:34 AM3/16/07
to activem...@googlegroups.com
Sorrry, require 'active_support' should be require 'active_merchant'

Cody Fauser

unread,
Mar 16, 2007, 9:41:03 AM3/16/07
to activem...@googlegroups.com
Ok, I'm totally out of it this morning. Just run the code as it is:

ActionView::Base.send(:include,
ActiveMerchant::Billing::Integrations::ActionViewHelper)

Note to self: don't write email before 10am.

kevinf4f

unread,
Mar 16, 2007, 12:29:52 PM3/16/07
to Active Merchant
This now works fine. I wouldn't have been able to work this one out,
so thanks again for your help and patience in dealing with this.

To summarise, I have added the following lines to environment,rb,
other code left as it was using the plugin:


require 'money'
require 'active_merchant'
require 'active_merchant/billing/integrations/action_view_helper'

ActionView::Base.send(:include,
ActiveMerchant::Billing::Integrations::ActionViewHelper)


Kevin

ma...@goodlife.tw

unread,
Apr 12, 2013, 2:59:34 AM4/12/13
to activem...@googlegroups.com, k.han...@btinternet.com
As an update, now I only need to have one line:


ActionView::Base.send(:include, ActiveMerchant::Billing::Integrations::ActionViewHelper)

In an initializer file under the config/initializers/ directory.

kevinf4f於 2007年3月17日星期六UTC+8上午12時29分52秒寫道:

Albi

unread,
Apr 8, 2015, 1:21:27 PM4/8/15
to activem...@googlegroups.com, k.han...@btinternet.com
I've added 'ActionView::Base.send(:include, ActiveMerchant::Billing::Integrations::ActionViewHelper)' in an initializer

But I still have this error: 
uninitialized constant ActiveMerchant::Billing::Integrations

What are the all steps to integrate Active Merchant gem to Rails 3.2.19?

Thanks in advance!
Alberto

Nathaniel Talbott

unread,
Apr 8, 2015, 2:16:31 PM4/8/15
to activem...@googlegroups.com
Albi,

The Integrations are no longer a part of ActiveMerchant; you'll want to switch to using the https://rubygems.org/gems/offsite_payments gem.

Hope this helps,

--
Nathaniel

--
You received this message because you are subscribed to the Google Groups "Active Merchant" group.
To unsubscribe from this group and stop receiving emails from it, send an email to activemerchan...@googlegroups.com.
To post to this group, send email to activem...@googlegroups.com.
Visit this group at http://groups.google.com/group/activemerchant.
For more options, visit https://groups.google.com/d/optout.

Reply all
Reply to author
Forward
0 new messages