16 May 20:42
Re: help needed with where and how best to set a param
From: AndyV <AndyVanasse@...>
Subject: Re: help needed with where and how best to set a param
Newsgroups: gmane.comp.lang.ruby.rails
Date: 2008-05-16 18:42:05 GMT
Subject: Re: help needed with where and how best to set a param
Newsgroups: gmane.comp.lang.ruby.rails
Date: 2008-05-16 18:42:05 GMT
Have you tried making this special route a :collection route instead of a :member route? If it were a collection route then the :id would be optional... but it might also solve the bigger problem more gracefully. In your popup action you could have something like this: @order = params[:id].nil? ? Order.new : Order.find_by_id(params[:id]) Then your view could build the url either for insert (new_record?) or update. If you're already taking advantage of the new Rails 'form_for @ivar' then it should be done for you. HTH, AndyV On May 15, 6:16 pm, Becca Girl <rails-mailing-l...@...> wrote: > Once again, I'm writing about a pop-up window issue and need some help. > Trying to insert a new record prior to the pop-up and other sorts of > things has proven to be a much bigger problem so instead I'll have a > default record that will serve as a placeholder for new pop-up window > values. > > In my main form, if I'm editing an order, the order id is sent to the > pop-up window. Then my pop-up window uses that information. If it's a > new order, the pop-up window doesn't have an order id. > > To work around this, I'd like to set a default order ID that I'll use > for new orders so that the pop-up window options work. > > My link to the pop-up looks like this: > > <%= link_to 'small window',{ :controller => 'codes', :action => > 'pop_up', > :id => @order}, :popup => ['codes', > 'width=450,height=600,menubar=no,resizable=yes,scrollbars=yes'] %> > > How can I override :id => @order so that I send in a default ID of 1? > > If anyone has other, better design ideas, I'd love to hear them. I > think I've exhausted all of the ones that I have seen. > -- > Posted viahttp://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@... To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe@... For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
RSS Feed