I'm trying to test if my values are existing... Not sure how to do this, I'm just starting to learn Ruby on Rails. Hopefully someone can point me to the right direction?
Lets say I have this block of codes:
@lv = {'apple' => ['red', 'round'], 'iPhone' => ['device', 'phone']}
if params[:var]
@lv.each do |key, tags|
if params[:var] == key
lvtags = @lv[params[key]]
lvtags.each do |tag|
@tags = client.tag_recent_media(tag)
end
end
end
end
I'm trying to see if the loop through the if params[:var] == key
works. I'd like to somehow output like an alert()
type thing, to test if key
has a value? Is there something like alert(key)
? where it'll show if key
has something? Or if I can test if lvtags
has a value that its supposed to pop out?
For instance, if ?var=0
Then I'd like to test alert(lvtags)
, and thus this is supposed to pop out apple
or something, some value associated to lvtags = @lv[params[key]]
. How do we normally test something like this in rails?
Thanks