Search code examples
ruby-on-railsurlstring-concatenation

Concatenate/append bitcoin address to image_tag source Rails


I have a hash that contains a bitcoin address. The hash looks like this:

{"status"=>"success", "data"=>{"user_id"=>2, "address"=>"2NE9LK7LGKr9dStvxpF64ucKyoywnfcLd1W", "label"=>"slesle91", "available_balance"=>"0.00000000", "pending_received_balance"=>"0.00000000"}}

I can display the bitcoin address via:

<%= @address["data"]["address"] %>

How can I add this to an image_tag to get a url like this that create a qr code:

<%= image_tag src="https://chart.googleapis.com/chart?chs=250x250&cht=qr&chl="2NE9LK7LGKr9dStvxpF64ucKyoywnfcLd1W" %>

So I am looking for a solution to do something similar to:

%= image_tag src="https://chart.googleapis.com/chart?chs=250x250&cht=qr&chl="<%= @address["data"]["address"] %>" %>

Any comment or assistance will be greatly appreciated.


Solution

  • I managed to resolve this in the following manner:

    <%= image_tag src="https://chart.googleapis.com/chart?chs=250x250&cht=qr&chl=#{@balance["data"]["address"]}" %>