mardi 7 mars 2017

Rails find id on the model

On controller usually use params to get id and on the model? i've trying to get using the exemple below:

in either case did not get id, so how to get the id or any attributes on the model?

def nook
   product = Product.find_by_id(:id)
   nook.product_id
end
def product
    prod = Product.find_by_id(attributes['product_id']) 
end

Aucun commentaire:

Enregistrer un commentaire