views:

53

answers:

2

Hi,

As a follow up for this question http://stackoverflow.com/questions/968799/returning-from-rails-controller how can I return false. I need to call the controller function to check for an ID.

If the ID exists I need to return true.

else return false

to return true, I am using : {render :nothing => true, :status => :ok}

thank you

A: 

Hi,

I am using below code. Is there a better way of solving this problem. 

if true
render :text => "true"
else
render :text => "false"
firemonkey
Please edit your question and include the content of this answer. Then delete this answer.
Simone Carletti
A: 

I don't understand if you need to write true/false as a string or if your method need to return a true/false value.

In the former case, assuming you have a conditions that evaluates true/false, you can do

def action
  render :text => condition
end
Simone Carletti