Files
project-work/worker-toolkit-stocks-in-the-future/repo/app/controllers/stocks_controller.rb
Eric Bell 2854619bc9 chore: init commit
in worker.../repo/GITFOLDER.zip is the .git folder.
2026-08-11 14:44:09 -04:00

27 lines
533 B
Ruby

# frozen_string_literal: true
class StocksController < ApplicationController
before_action :set_stock, only: %i[show]
before_action :authenticate_user!
before_action :set_portfolio
def index
@stocks = policy_scope(Stock).includes(portfolio_stocks: :portfolio)
@portfolio = current_user.portfolio if current_user.student?
end
def show
authorize @stock
end
private
def set_portfolio
@portfolio = current_user.portfolio
end
def set_stock
@stock = Stock.find(params.expect(:id))
end
end