I’m playing around with the Ruby Twitter gem, which, for example, allows you to check if a Twitter user’s account is locked. The user’s account I am testing is locked.
If I do
@awish = Twitter.user("twitteruser").protected?
and then in a view do
<%= @awish %>
it says “true”
However. when I try to write a method to test this and assign the response to a variable depending on whether it’s locked or not, it’s telling me that it’s “not locked”, when I would be expecting it to say it’s “locked”. So I think I’ve screwed up this if/else statement somehow (note, I’m a bit of a noob)
Can you explain what I’ve done wrong?
def awisprotect
@awish = Twitter.user("twitteruser").protected?
if @awish == "true"
@answer = "locked"
else
@answer = "not locked"
end
render :js => "$('div.awishanswer').html(' #{ @answer } ');"
end
The “true” isn’t a string, remove the quotes and it should be fine.