text: Q:
  
  Using a has_many and belongs_to relationship, I need to display the parameters of each resource in one index view
  
  I have 2 models, my schema looks like this: 
  ActiveRecord::Schema.define(version: 20140322214021) do
  
    create_table "transactions", force: true do |t|
      t.datetime "created_at"
      t.datetime "updated_at"
      t.string   "product"
      t.integer  "price"
      t.integer  "user_id"
    end
  
    create_table "users", force: true do |t|
      t.datetime "created_at"
      t.datetime "updated_at"
      t.string   "barcode"
      t.string   "name"
      t.string   "email"
    end
  
  end
  
  I want to display the user's name, the price of the transaction, and the product, all in the transactions index view. I particularly want to be able to add up the number of products the user has bought, as well as add the total price per user.
  I am able to get the user object to print out, and the product and price. This is what I have so far:
  <h1>Listing transactions</h1>
  
  <table>
    <thead>
      <tr>
        <th>Attendee</th>
        <th>Drink</th>
        <th>Price</th>
      </tr>
    </thead>
  
    <tbody>
      <% @transactions.each do |transaction| %>
        <tr>
          <td><%= transaction.user %></td>
          <td><%= transaction.product %></td>
          <td><%= transaction.price %></td>
        </tr>
      <% end %>
    </tbody>
  </table>
  
  My create user action:
    def create
      @user = User.new(user_params)
      @user.transactions.build(params[:user][:transaction])
      if @user.save
        redirect_to root_url, notice: "Thank you for signing up!"
      else
        render "new"
      end
    end
  
  My transactions index action:
    def index
     @transactions = Transaction.all
  
      respond_to do |fmt|
        fmt.json { render json: @transactions }
        fmt.html { render action: 'index' }
      end
    end
  
  My user_params:
    def user_params
      params.require(:user).permit(:name, :email, :barcode)
    end
  
  I have been able to do something like <%= transaction.user.name %> in the past with a join table, but its not happening here.
  If I go to users#index, I get an error ActiveRecord::RecordNotFound at /users
  Couldn't find User without an ID
  Thank you very much.
  
  A:
  
  ActiveRecord::RecordNotFound at /users Couldn't find User without an
    ID
  
  This could mean several things
  
  Routes
  You need to make sure you're accessing the right data
  According to the routes documentation, you should only show collections of data in your index action. This error typically happens if you browse to users/show without any ID:
  #config/routes.rb
  resources :users, :transactions
  
  If you're a beginner, this is how the RESTful routing structure would look:
  
  Data
  If you're accessing @transactions = Transaction.all, the issue may be with how you're storing your data:
  create_table "transactions", force: true do |t|
      t.datetime "created_at"
      t.datetime "updated_at"
      t.string   "product"
      t.integer  "price"
      t.integer  "user_id"
  end
  
  I don't think you're storing user_id for each transaction. When you create a new transaction, you need to pass the user_id to your model, otherwise it won't store the data correctly
  We normally do this by using the .merge method in your params:
  def user_params
      params.require(:user).permit(:name, :email, :barcode).merge(user_id: current_user.id)
  end
  
  