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 ... --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
On 2/6/08, KTU <ketuomin-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> > 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 :-) [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> 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 ... > > >--~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
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 On Feb 6, 10:45 pm, "Frederick Cheung" <frederick.che...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> On 2/6/08, KTU <ketuo...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: > > > > > 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 :-) [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 > > > 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 ...--~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
ESPNDev-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org
2008-Feb-06 22:16 UTC
Re: redirect to new action not working ?
Is params[:agreement] supposed to be a boolean? If not what other possible values are there? Could you mean ''true''? On Feb 6, 1:23 pm, KTU <ketuo...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> 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 > > On Feb 6, 10:45 pm, "Frederick Cheung" <frederick.che...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> > wrote: > > > On 2/6/08, KTU <ketuo...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: > > > > 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 :-) [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 > > > > 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 ...--~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
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. On Feb 7, 12:16 am, "ESPN...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org" <ESPN3.DL- Community...-xX8xgfAcNKEAvxtiuMwx3w@public.gmane.org> wrote:> Is params[:agreement] supposed to be a boolean? If not what other > possible values are there? > Could you mean ''true''? > > On Feb 6, 1:23 pm, KTU <ketuo...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: > > > 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 > > > On Feb 6, 10:45 pm, "Frederick Cheung" <frederick.che...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> > > wrote: > > > > On 2/6/08, KTU <ketuo...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: > > > > > 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 :-) [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 > > > > > 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 ...--~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
ok i found how to do it: if @imitem.agreement == true On Feb 7, 12:25 am, KTU <ketuo...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> 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. > > On Feb 7, 12:16 am, "ESPN...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org" <ESPN3.DL- > > Community...-xX8xgfAcNKEAvxtiuMwx3w@public.gmane.org> wrote: > > Is params[:agreement] supposed to be a boolean? If not what other > > possible values are there? > > Could you mean ''true''? > > > On Feb 6, 1:23 pm, KTU <ketuo...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: > > > > 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 > > > > On Feb 6, 10:45 pm, "Frederick Cheung" <frederick.che...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> > > > wrote: > > > > > On 2/6/08, KTU <ketuo...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: > > > > > > 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 :-) [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 > > > > > > 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 ...--~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
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. On Feb 6, 2:25 pm, KTU <ketuo...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> 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. > > On Feb 7, 12:16 am, "ESPN...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org" <ESPN3.DL- > > Community...-xX8xgfAcNKEAvxtiuMwx3w@public.gmane.org> wrote: > > Is params[:agreement] supposed to be a boolean? If not what other > > possible values are there? > > Could you mean ''true''? > > > On Feb 6, 1:23 pm, KTU <ketuo...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: > > > > 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 > > > > On Feb 6, 10:45 pm, "Frederick Cheung" <frederick.che...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> > > > wrote: > > > > > On 2/6/08, KTU <ketuo...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: > > > > > > 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 :-) [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 > > > > > > 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 ...--~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---