lundi 18 mai 2015

MVC Logic and Active Record example Rails

I want to ask two things:

1) In the MVC logic of Rails , is correct to call a Model into another Model? In other words:

Model A.rb

def function1 ... end

Model B.rb

def function2 A.function1 end

This is just an example and there isn't any association between the two Models.

The second question is:

2) When i call in the Rails console: c = Supply.where(product_id: 7) i have this result

enter image description here

and i'm not able to call: c.quantity

If i use c = Supply.find(1) i can call c.quantity

enter image description here

What is the difference?

Thanks all

enter image description here

Aucun commentaire:

Enregistrer un commentaire