L
L
lavezzi12015-09-03 15:50:39
Ruby on Rails
lavezzi1, 2015-09-03 15:50:39

if doesn't work, what am I doing wrong?

Hello.
There is a helper

module ArticlesHelper
  def image_from_amazon(amazon_id)
    	image_tag "http://images.amazon.com/images/P/#{amazon_id}.01.ZTZZZZZZ.jpg"
  end
end

I try like this
module ArticlesHelper
  def image_from_amazon(amazon_id)
    if amazon_id == nil
      image_tag "http://vk.com/images/deactivated_100.png"
    else
    		image_tag "http://images.amazon.com/images/P/#{amazon_id}.01.ZTZZZZZZ.jpg"
    	end
  end
end

As a result, the picture is not placed, but on the page it displays
<img src="http://images.amazon.com/images/P/.01.ZTZZZZZZ.jpg" alt=".01.ztzzzzzz">

Answer the question

In order to leave comments, you need to log in

2 answer(s)
T
TyzhSysAdmin, 2015-09-03
@lavezzi1

Are you sure amazon_id is nil?
==''

A
Anatoly Egorov, 2015-09-06
@alxrt

If you are using Rails, then it is amazon_id == nilwiser to use amazon_id.blank?

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question