On Mon, Feb 21, 2011 at 3:38 PM, Colin Law <[email protected]> wrote:
> On 21 February 2011 03:34, James allan To <[email protected]> wrote: > > Hi I would just like to ask if someone can point me to the right > > direction. I have an order page which will need to be split into 3 views > > before saving say in controller: > > > > def new > > @order = Order.new > > end > > > > def process_new > > @order = Order.new(params[:order]) > > #do validation for new > > # redirect to no_of_attendees > > end > > > > def no_of_attendees > > @order = Order.new(params[:order]) > > end > > > > def process_no_of_attendees > > @order = Order.new(params[:order]) > > #do validation > > #redirect to save page > > end > > > > Question: Is there aright way of doing this (carry params values between > > views) or should I just place the data from new in session as we move to > > forward to the third page create a hash from session and save in model? > > If all you are passing back each time is the latest data for the > order, so you can do Order.new(params[:order]) as you have shown, then > there is no reason to complicate things by using the session. > > this is fine as long as you place the attributes in the previous step in a hidden field so it will not be lost when you submit the form. > You might like to consider whether the controller (and maybe the view) > would be simplified by combining the actions (and maybe views) and > passing up and back a phase value to indicate which phase of the > operation is current. > > Make sure you do the validation in the model so that at each action > you are just asking the model to validate itself, rather than putting > validation code in the controller. > > Colin > > -- > 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 [email protected]. > To unsubscribe from this group, send email to > [email protected]. > For more options, visit this group at > http://groups.google.com/group/rubyonrails-talk?hl=en. > > -- ------------------------------------------------------------- visit my blog at http://jimlabs.heroku.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 [email protected]. To unsubscribe from this group, send email to [email protected]. For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.

