Reputation: 2109
How can I retrive values from my rails3 model and display it on console. I tried the below code which display some Hash value. Do suggest me how to display individual values of model.
@links = Domainurl234.all
puts @links
Upvotes: 1
Views: 2333
Reputation: 6728
Use each method to print individual values of @links
@links = Domainurl234.all
@links.each { |link| p link }
Upvotes: 2
Reputation: 8954
You can simply load the object (you dont need the @, tahts for instance variables only) and then you can access the attributes in object orientated style.
object=Model.find(<id>)
object.attribute_name
If you dont know the attributes of Model
you can simply write down the models name and the attributes will be displayed.
Upvotes: 2