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?
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?
Hamlを使用する
%h2
#{@project.name}
また
%h2
#{org.id}
私はあなたがその方法を望むかもしれないと思います.inspect
。
= val.inspect
それはあなたに次のようなものを表示します:
#<ShortenedURL @url="the url", @count=0, @etc="etc">
もちろん、詳細に飛び込みたい場合(たとえば、誰かにurl
属性(またはあなたが持っている可能性のある属性)だけを表示したい場合は、その方法を使用します。
= val.url
表示されます:
the url