Rails: Dynamic Select On Multistep Form Not Keeping Selected
I am working on a multistep form for an order placement process following Ryan Bates's Multistep Tutorial #217 which uses a session. On the first step I have two select fields: one
Solution 1:
@shippingservices = @cart.available_shipping_services.joins(:lands).where(:lands => {:id => session[:cart_params]})
This was not correctly using the session[:cart_params]
to get the land_id
in order to set the orders land when moving back through the form. We can instead use @order = Order.new(session[:order_params])
defined one line above to grab @order.land_id
and not have to rely on any of the sessions.
I would also add an existence check if there is a possibility of an Order being initialized without a corresponding Land.
Post a Comment for "Rails: Dynamic Select On Multistep Form Not Keeping Selected"