Reputation: 732
I'm using Postgresql
and I'm not sure what I'm missing here, but calling my database in my
helper.rb:
def get_info
info = Scraper.find(1)
puts info
end
in my controller.rb via a post request, like such:
def create
helpers.get_info
end
is returning
#<Scraper:0x00007f96f9738ce0>
As opposed to the actual information from my database:
<Scraper id: 1, restaurant: => "subway">
Upvotes: 3
Views: 129
Reputation: 2004
Modify following code
def get_info
info = Scraper.find(1)
puts info
end
as
def get_info
Scraper.find(1)
end
This will work, no need to use puts info
or even if you want to use puts
then you can use
puts info.inspect
Upvotes: 3
Reputation: 1254
puts
prints class and Object Id for complex object. To print details about object, you can use inspect
:
puts info.inspect
For more details, you can checkout here: https://vitobotta.com/2011/01/17/prettier-user-friendly-printing-of-ruby-objects/
Upvotes: 2
Reputation: 5942
puts info.inspect
I suggest you to read the ruby on rails documentation
Upvotes: 1