I'm trying yo create a service object to extract a few methods from the product.rb
AR model, but for some reason I can't autoload the new TwitterShare
class. When I hit up the console and try something like Product.last.twitter_share_text
I get NameError: uninitialized constant Product::TwitterShare
error.
What's going on in here? How should I organize my folders/files? Do I have to tell rails to autoload services? Here is the current code:
app/models/product.rb
class Product < ActiveRecord::Base
def twitter_share_text
TwitterShare.new(name: self.name, oneliner: self.oneliner).return_text
end
app/services/twitter_share.rb
class TwitterShare
attr_reader .........
def initialize....
end