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?
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
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 -
--~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
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.
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
ActionView::Base.send(:include,
ActiveMerchant::Billing::Integrations::ActionViewHelper)
Note to self: don't write email before 10am.
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
uninitialized constant ActiveMerchant::Billing::Integrations
--
You received this message because you are subscribed to the Google Groups "Active Merchant" group.
Visit this group at http://groups.google.com/group/activemerchant.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.
For more options, visit https://groups.google.com/d/optout.