Hi All,

I'm making my first extension and as part of it I need to add some
functionality to some of the model classes.

I started with the Logic Customisation tutorial and made the first 2
changes:

1. Added the decorator to my extension.rb file
Dir.glob(File.join(File.dirname(__FILE__), "../app/**/*_decorator*.rb")) do
c|
Rails.configuration.cache_classes ? require(c) : load(c)
end

2. Created a product_decorator.rb and placed it in
app/models/spree/product_decorator.rb
Spree::Product.class_eval do
def some_method
#Empty for now
end
end

I fired up rails and received the following error:
rails.rb:46:in 'configuration': undefinied method 'config' for nil:NilClass
(NoMethodError)

I'm guessing this means that Rails.configuration is nil or something.

Has anyone got this working? Are you able to tell me where I went wrong?

Thanks in advance.

Cheers,

Jo

--
You received this message because you are subscribed to the Google Groups "Spree" group.
To view this discussion on the web visit https://groups.google.com/d/msg/spree-user/-/lz7mAdtz2dkJ.
To post to this group, send email to spree-user@googlegroups.com.
To unsubscribe from this group, send email to spree-user+unsubscribe@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/spree-user?hl=en.

Search Discussions

  • Nate Lowrie at Dec 18, 2012 at 9:50 pm
    Jo,

    Try using this structure instead the code you got for step 1

    config.autoload_paths += %W(#{config.root}/lib) def self.activate Dir.glob(File.join(File.dirname(__FILE__), "../app/overrides/*.rb")) do |c| Rails.application.config.cache_classes ? require(c) : load(c) end Dir.glob(File.join(File.dirname(__FILE__), "../app/**/*_decorator*.rb")) do |c| Rails.configuration.cache_classes ? require(c) : load(c) end end config.to_prepare &method(:activate).to_proc


    Regards,


    Nate

    On Monday, December 17, 2012 9:25:06 PM UTC-5, jodi...@gmail.com wrote:

    Hi All,

    I'm making my first extension and as part of it I need to add some
    functionality to some of the model classes.

    I started with the Logic Customisation tutorial and made the first 2
    changes:

    1. Added the decorator to my extension.rb file
    Dir.glob(File.join(File.dirname(__FILE__), "../app/**/*_decorator*.rb"))
    do |c|
    Rails.configuration.cache_classes ? require(c) : load(c)
    end

    2. Created a product_decorator.rb and placed it in
    app/models/spree/product_decorator.rb
    Spree::Product.class_eval do
    def some_method
    #Empty for now
    end
    end

    I fired up rails and received the following error:
    rails.rb:46:in 'configuration': undefinied method 'config' for
    nil:NilClass (NoMethodError)

    I'm guessing this means that Rails.configuration is nil or something.

    Has anyone got this working? Are you able to tell me where I went wrong?

    Thanks in advance.

    Cheers,

    Jo
    --
    You received this message because you are subscribed to the Google Groups "Spree" group.
    To view this discussion on the web visit https://groups.google.com/d/msg/spree-user/-/_bT1F1IC3dQJ.
    To post to this group, send email to spree-user@googlegroups.com.
    To unsubscribe from this group, send email to spree-user+unsubscribe@googlegroups.com.
    For more options, visit this group at http://groups.google.com/group/spree-user?hl=en.

Related Discussions

Discussion Navigation
viewthread | post
Discussion Overview
groupspree-user @
categoriesrubyonrails
postedDec 18, '12 at 3:05p
activeDec 18, '12 at 9:50p
posts2
users2
websitespreecommerce.com
irc#RubyOnRails

2 users in discussion

Jodimo42: 1 post Nate Lowrie: 1 post

People

Translate

site design / logo © 2022 Grokbase