Hey guys, How can we give two form_for based on conditions? I mean like this:- unless condition1.nil? form_for :abc, :url => { :action => "123" } do |f| else form_for :abc, :url => { :action => "234" } do |f| end This is not working. Can you guyz tell me where is the problem ? How can i write this scenario. -- Posted via http://www.ruby-forum.com/. -- 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-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
Hemant Bhargava wrote:> Hey guys, > > How can we give two form_for based on conditions? I mean like this:- > > unless condition1.nil? > form_for :abc, :url => { :action => "123" } do |f| > else > form_for :abc, :url => { :action => "234" } do |f| > end > > This is not working. Can you guyz tell me where is the problem ?The problem is that form_for takes a block. You can''t write only half a block before else. Also, unless...else doesn''t make sense. Use if...else.> How can > i write this scenario.In the controller: @action = condition1.nil? ? ''234'' : ''123'' And in the view: form_for :abc, :url => {:action => @action} do |f| Best, -- Marnen Laibow-Koser http://www.marnen.org marnen-sbuyVjPbboAdnm+yROfE0A@public.gmane.org -- Posted via http://www.ruby-forum.com/. -- 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-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe@googlegroups.com. For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
> > @action = condition1.nil? ? ''234'' : ''123''Thanks for a quickie dude.. Resolved .. :)> > And in the view: > > form_for :abc, :url => {:action => @action} do |f| > > Best, > -- > Marnen Laibow-Koser > http://www.marnen.org > marnen-sbuyVjPbboAdnm+yROfE0A@public.gmane.org-- Posted via http://www.ruby-forum.com/. -- 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-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe@googlegroups.com. For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.