redirect to new action not working ?

any idea what's wrong here: agreement return either 0 or 1

  def select
    @imitem = Imitem.find(params[:id])

if [params[:agreement] == 'True']
redirect_to :action => 'agreement', :id => @imitem and return false
else
redirect_to :action => 'options', :id => @imitem and return
end
end

it always goes to agreement action no matter what ...

any idea what's wrong here: agreement return either 0 or 1

  def select
    @imitem = Imitem.find(params[:id])

if [params[:agreement] == 'True']

This isn't bash :slight_smile: [params[:agreement] == 'True'] is an array
containing one element, this isn't nil or false and so is always
handled as true by the if. Remove the outer square brackets and you
should be ok.

Fred

Well I removed those ie. its now (agreement value on database is
either 1 or 0)

if params[:agreement] == 'True'
redirect_to :action => 'agreement', :id => @imitem and return
else
redirect_to :action => 'options', :id => @imitem and return
end
end

but now it goes to options action all the time

Is params[:agreement] supposed to be a boolean? If not what other
possible values are there?
Could you mean 'true'?

Hi

agreement on database has value either 0 (zero) or 1 (one). Now I try
to check if that value is 1 (true) and then it should
take route (action) to agreement and if not then route (action) should
go to options.

I tested with all possible values like: True / true / 1 ... but all
those fails...

is that whole statement then wrong somehow... I am still waiting good
book and its hard to find proper examples from the net.

ok i found how to do it:

if @imitem.agreement == true

For a good book I would check out 'The Rails Way' published by Addison
Wesley.

I have some examples on my blog: http://matthewcarriere.com

And feel free to email me with a posting topic you would like to see.