I have a variabla var. If I try to output its value in HAML like =val then I just get the string value of the object which looks like this: #<ShortenedUrl:0x118c50fa
.
But how do I get the value that is in there?
Using Haml
%h2
#{@project.name}
or
%h2
#{org.id}
I think you may want the .inspect
method.
= val.inspect
That will show you something like:
#<ShortenedURL @url="the url", @count=0, @etc="etc">
Of course, if you want to dive in to specifics (for example, you only want to show someone the url
attribute (or whatever attribute you may have), then use that method:
= val.url
Which will show:
the url
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With