tyrauber / stock_quote

A ruby gem that retrieves stock quotes from IEX
MIT License
211 stars 55 forks source link

This version does not work #57

Closed Pandop closed 6 years ago

Pandop commented 6 years ago

Hi,I'm currently using stock_quote version 2.0.0. I have installed the gem using "bundle install" and included the necessary code snippet as below. However, When the code is run from browser using "localhost:3000", the server terminates suddenly with the following error.

C:/tools/ruby25/lib/ruby/gems/2.5.0/gems/activerecord-5.2.0/lib/active_record/log_subscriber.rb:98 Processing by HomeController#index as HTML Rendering home/index.html.erb within layouts/application Segmentation fault

The browser gives this error: "This site can't be reached. ERR_CONNECTION RESET."

Below is my code.

Segment code inside the gemFile

ruby '2.5.1'
# Bundle edge Rails instead: gem 'rails', github: 'rails/rails'
gem 'rails', '~> 5.2.0'
gem 'mysql2', '>= 0.4.4', '< 0.6.0'
gem 'puma', '~> 3.11'
gem 'jquery-rails'
gem 'autoprefixer-rails'
gem 'bootstrap-sass', '~> 3.3.7'
gem 'bootstrap', '~> 4.0.0'
gem 'stock_quote', '~> 2.0.0'

home_controller.rb

class HomeController < ApplicationController
  def index
    #@stock = StockQuote::Stock.quote("goog")
  end
  def about
  end
end

Index.html.erb

<h1>STOCKER</h1>
<p>This is from Stocker page!</p>
<%= StockQuote::Stock.quote('aapl') %>

I'd appreciate your help on the above as I cannot proceed with the course from this point forward.

Thanks.

tyrauber commented 6 years ago

Hi @Pandop I do not believe this is an issue with the gem but your application or environment. I just tested the gem and it is working:

$ irb
2.3.1 :001 > require 'rubygems'
 => false 
2.3.1 :002 > require 'stock_quote'
 => true 
2.3.1 :003 > StockQuote::Stock.quote('aapl')
 => #<StockQuote::Stock:0x007fdbe0a557d0 @symbol="AAPL", @company_name="Apple Inc.", @primary_exchange="Nasdaq Global Select", @sector="Technology", @calculation_price="close", @open=194.16, @open_time=1528378200576, @close=193.46, @close_time=1528401600319, @high=194.2, @low=192.335, @latest_price=193.46, @latest_source="Close", @latest_time="June 7, 2018", @latest_update=1528401600319, @latest_volume=21252573, @iex_realtime_price=193.5, @iex_realtime_size=7, @iex_last_updated=1528401591973, @delayed_price=193.46, @delayed_price_time=1528401600319, @extended_price=193.46, @extended_change=0, @extended_change_percent=0, @extended_price_time=1528405105000, @previous_close=193.98, @change=-0.52, @change_percent=-0.00268, @iex_market_percent=0.02604, @iex_volume=553417, @avg_total_volume=28250502, @iex_bid_price=0, @iex_bid_size=0, @iex_ask_price=0, @iex_ask_size=0, @market_cap=950882597480, @pe_ratio=19.88, @week52_high=194.08, @week52_low=142.2, @ytd_change=0.13235977437295748, @attribution="Data provided for free by IEX (https://iextrading.com/developer).", @response_code=200> 

The error suggests there is something wrong with your layout.