Monday 15 September 2014

activerecord - jruby on rails retrive attributes in hash -


I have successfully added my model to a remote networkzza database, do I have data from the database in "Rail C" Can recover:

For example

  & gt; Cars.First & gt; # & Lt; Car ID: 10, Model: "Ford xxxxxxx" & gt;   

However, I can not retrieve hash:

  & gt; Cars.First MODELNAME (=> zero) & gt; Cars. First [MODELNAME]] (10)   

Anyway can I force an active record hash object or me?

I do not know how you can do such properties "model" or "model" before the capital entity Is not allowed because they constantly represent the second "model" is definitely a reserved word, you can not use this word independently. Thirdly, the name of the model is not a "car" in a convention Model Name is singular goes.

However, if your model name is "car" and the name of the specialty is "model_name", which is legal, then you can get value from a hash by a symbol

  car. First [: model_name]    

No comments:

Post a Comment