Reputation: 8961
I'm trying to write a rails app that creates an object in the controller based on a helper module, which is written below:
module StockPricesHelper
require 'net/http'
class Stock
attr_accessor(:data)
def initialize(stock)
@url = "http://finance.yahoo.com/d/quotes.csv?s=#{stock}&f=sb2b3jk"
end
def download_data
@data = NET::HTTP.get_response(URI.parse(@url)).body
end
def clean_string
@data = @data.strip
end
def db_format
1
end
end
end
I get an error uninitialized constant StockPricesHelper::Stock::NET
from the rails server.
Upvotes: 0
Views: 154
Reputation: 72514
You have misspelled the "NET" module. It is Net
. (Ruby is case sensitive)
Rails helpers are intended to be view helpers, i.e. aid in generating HTML. It looks like you are performing something which would be better placed in a controller or background job.
Upvotes: 4