samedi 11 mars 2017

Rails Couldn't find Object without an ID

I'm trying to get the order of shop orders but Couldn't find Order without an ID error appear

ActiveRecord::RecordNotFound (Couldn't find Order without an ID)

i tried

 @order = Order.where("id = ? AND shop_id = ?", params[:id], @shop.id )

and another error

so, someone knows how to get the object from the associated objects?

class OrdersController < ApplicationController


def sold

  @shop = current_user.shop
@order =  @shop.orders.find(params[:id])

  end 
  end

Aucun commentaire:

Enregistrer un commentaire