title: NoMethodError in Stocks#show
body: <p>I'm trying to create a stock market app and I have a button that is breaking my web app. My issue is with this bit of embedded ruby on my</p>
  <p>show.html.erb page:</p>
  <pre><code>&lt;%= render @stock %&gt;
  &lt;div&gt;
    &lt;%= link_to &quot;Edit this stock&quot;, edit_stock_path(@stock) %&gt; |
    &lt;%= link_to &quot;Back to stocks&quot;, stocks_path %&gt;
    &lt;%= button_to &quot;Delete this stock&quot;, @stock, method: :delete %&gt;
  &lt;/div&gt;
  </code></pre>
  <p>This<code>@stock.destroy</code> line is needed for removing entries for a user. The error rails throws:</p>
  <pre><code>Showing C:/stockmarketapp/app/views/stocks/show.html.erb where line #9 raised:
  
  undefined method `destroy' for #&lt;StockQuote::Stock:0x000001f7fc0aa780 @attribution=&quot;Data provided for free by IEX (https://iexcloud.io).&quot;,
  @response_code=200, @avg_total_volume=2261555,
  @calculation_price=&quot;close&quot;, @change=-0.36, @change_percent=-0.00331,
  @close=108.41, @close_source=&quot;official&quot;, @close_time=1654286400058,
  @company_name=&quot;BlackRock Institutional Trust Company N.A. - iShares Core High Dividend ETF&quot;, @currency=&quot;USD&quot;, @delayed_price=108.4,
  @delayed_price_time=1654286390674, @extended_change=0, @extended_change_percent=0, @extended_price=108.41,
  @extended_price_time=1654300800004, @high=108.93, @high_source=&quot;15
  minute delayed price&quot;, @high_time=1654286395170, @iex_ask_price=nil,
  @iex_ask_size=nil, @iex_bid_price=nil, @iex_bid_size=nil,
  @iex_close=108.43, @iex_close_time=1654286330444,
  @iex_last_updated=nil, @iex_market_percent=nil, @iex_open=108.81,
  @iex_open_time=1654263316934, @iex_realtime_price=nil,
  @iex_realtime_size=nil, @iex_volume=nil,
  @last_trade_time=1654286394157, @latest_price=108.41,
  @latest_source=&quot;Close&quot;, @latest_time=&quot;June 3, 2022&quot;,
  @latest_update=1654286400058, @latest_volume=876363, @low=108.25,
  @low_source=&quot;15 minute delayed price&quot;, @low_time=1654273215082,
  @market_cap=13133871500, @odd_lot_delayed_price=108.395,
  @odd_lot_delayed_price_time=1654286390033, @open=108.33,
  @open_time=1654263000128, @open_source=&quot;official&quot;, @pe_ratio=nil,
  @previous_close=108.77, @previous_volume=1062893,
  @primary_exchange=&quot;NYSE ARCA&quot;, @symbol=&quot;HDV&quot;, @volume=876363,
  @week52_high=110.91, @week52_low=91.09,
  @ytd_change=0.07801100501710605, @is_us_market_open=false&gt;
  Extracted source (around line #9):78910
                
    &lt;%= link_to &quot;Edit this stock&quot;, edit_stock_path(@stock) %&gt; |
    &lt;%= link_to &quot;Back to stocks&quot;, stocks_path %&gt;
    &lt;%= button_to &quot;Delete this stock&quot;, @stock.destroy, method: :delete %&gt;
  &lt;/div&gt;
  
  Rails.root: C:/stockmarketapp
  
  Application Trace | Framework Trace | Full Trace
  app/views/stocks/show.html.erb:9
  
  </code></pre>
  <p>These are my files related to <code>@stock</code> and <code>@stock.destroy</code>:</p>
  <pre><code>class StocksController &lt; ApplicationController
    before_action :set_stock, only: %i[ show edit update destroy ]
    before_action :correct_user, only: [:show, :edit, :update, :destroy]
    before_action :authenticate_user!
    @api = StockQuote::Stock.new(api_key: &quot;pk_153e93f4bce64c3d87e7d4d3510153ed&quot;)
  
  
    # GET /stocks or /stocks.json
    def index
      @stocks = Stock.all
    end
  
    # GET /stocks/1 or /stocks/1.json
    def show
      @stocks = Stock.all
    end
  
    # GET /stocks/new
    def new
      @stock = Stock.new
    end
  
    # GET /stocks/1/edit
    def edit
    end
  
    # POST /stocks or /stocks.json
    def create
      @stock = Stock.new(stock_params)
  
      respond_to do |format|
        if @stock.save
          format.html { redirect_to stock_url(@stock), notice: &quot;Stock was successfully created.&quot; }
          format.json { render :show, status: :created, location: @stock }
        else
          format.html { render :new, status: :unprocessable_entity }
          format.json { render json: @stock.errors, status: :unprocessable_entity }
        end
      end
    end
  
    # PATCH/PUT /stocks/1 or /stocks/1.json
    def update
      respond_to do |format|
        if @stock.update(stock_params)
          format.html { redirect_to stock_url(@stock), notice: &quot;Stock was successfully updated.&quot; }
          format.json { render :show, status: :ok, location: @stock }
        else
          format.html { render :edit, status: :unprocessable_entity }
          format.json { render json: @stock.errors, status: :unprocessable_entity }
        end
      end
    end
  
    # DELETE /stocks/1 or /stocks/1.json
    def destroy
      @stock.destroy
  
      respond_to do |format|
        format.html { redirect_to stocks_url, notice: &quot;Stock was successfully destroyed.&quot; }
        format.json { head :no_content }
      end
    end
  
    def correct_user
      @ticker = current_user.stocks.find_by(id: params[:id])
      redirect_to stocks_path, notice: &quot;Not Autherized to edit this stock&quot; if @ticker.nil?
    end
  
    private
      # Use callbacks to share common setup or constraints between actions.
      def set_stock
        @stock = Stock.find(params[:id])
      end
  
      # Only allow a list of trusted parameters through.
      def stock_params
        params.require(:stock).permit(:ticker, :user_id)
      end
  end
  
  </code></pre>
  <p>Stock partial:</p>
  <pre><code>
    &lt;% @stock= StockQuote::Stock.quote(stock.ticker) %&gt;
  
    &lt;div id=&quot;&lt;%= dom_id stock %&gt;&quot;&gt;
      &lt;p&gt;
        &lt;strong&gt;Ticker:&lt;/strong&gt;
        &lt;%= @stock.symbol %&gt;
      &lt;/p&gt;
      &lt;p&gt;
        &lt;strong&gt;Open&lt;/strong&gt;
       $&lt;%= @stock.open %&gt;
      &lt;/p&gt;
      &lt;p&gt;
        &lt;strong&gt;Price&lt;/strong&gt;
       $&lt;%= @stock.latest_price %&gt;
      &lt;/p&gt;
      &lt;p&gt;
        &lt;strong&gt;Close&lt;/strong&gt;
       $&lt;%= @stock.close %&gt;
      &lt;/p&gt;
      &lt;p&gt;
        &lt;strong&gt;Company Name&lt;/strong&gt;
        &lt;%= @stock.company_name %&gt;
      &lt;/p&gt;
      &lt;p&gt;
        &lt;strong&gt;Primary Exchange&lt;/strong&gt;
        &lt;%= @stock.primary_exchange %&gt;
      &lt;/p&gt;
      &lt;p&gt;
        &lt;strong&gt;Volume&lt;/strong&gt;
        &lt;%= number_with_delimiter(@stock.volume, :delimiter =&gt; ',') %&gt;
      &lt;/p&gt;
      &lt;p&gt;
        &lt;strong&gt;Market Cap&lt;/strong&gt;
        $&lt;%= number_with_delimiter(@stock.market_cap, :delimiter =&gt; ',') %&gt;
      &lt;/p&gt;
      
  
    &lt;/div&gt;
  
  </code></pre>
  <p>Github Repo: <a href="https://github.com/Maikkeru/Stockmarketapp" rel="nofollow noreferrer">https://github.com/Maikkeru/Stockmarketapp</a></p>
  <p>I assume that am wielding the stock object incorrectly but I don't know where that slipup is occurring. Thanks for your time.</p>