Hi Hillary, What they are proposing could be accomplished one of two ways.
1) Adding a route to your routes file post '/goals/building/build(.:format)', :to => "goals/build#create" 2) modifying to_param to look something like this app/models/goal.rb class Goal def to_param if new_record? 'building' else super end end end I would go with option 1 since it would have fewer side effects. Rob On August 18, 2013 at 12:17:13 , Hillary Hueter ([email protected]) wrote: I'm trying to build an object using a wicked wizard. One part of the walkthrough on the wiki that's confusing me is this paragraph: This also means to get to the create action we don't have a product_id yet so we can either create this object in another controller and redirect to the wizard, or we can use a route with a placeholder product_id such as [POST] /products/building/build in order to hit this create action. So i get that i have to create a blank product (or in my case a goal) so that i'll have an id that can be used by the show and update actions. I don't really want to start the wizard off in another controller, because that doesn't really make sense since the first step of the wizard is choosing a type and not entering the minimally viable information for that object. So i'd like to do the route with the placeholder that creates the object and then re-directs to the first step of the wizard. However i'm very confused about how to link to the create action from the Users dashboard page, or for testing what url to enter into the address bar. This is my controller class Goals::BuildController < ApplicationController include Wicked::Wizard steps :goal_length, :goal_type, :goal_info def show @goal = Goal.find(params[:goal_id]) render_wizard end def update @goal = Goal.find(params[:goal_id]) @goal.update_attributes(params[:goal]) render_wizard @goal end def create @goal = Goal.create Rails.logger info @goal.id redirect_to wizard_path(steps.first, :goal_id => @goal.id) end protected def goal_params params[:goal].permit(:name, :amount, :end_date, :goal_type, :goal_term, :on_going) end end My routes.rb has the following entry: resources :goals do resources :build, controller: 'goals/build' end These are the routes generated by that entry: POST /goals/:goal_id/build(.:format) goals/build#create new_goal_build GET /goals/:goal_id/build/new(.:format) goals/build#new edit_goal_build GET /goals/:goal_id/build/:id/edit(.:format) goals/build#edit goal_build GET /goals/:goal_id/build/:id(.:format) goals/build#show -- -- SD Ruby mailing list [email protected] http://groups.google.com/group/sdruby --- You received this message because you are subscribed to the Google Groups "SD Ruby" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. For more options, visit https://groups.google.com/groups/opt_out. -- -- SD Ruby mailing list [email protected] http://groups.google.com/group/sdruby --- You received this message because you are subscribed to the Google Groups "SD Ruby" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. For more options, visit https://groups.google.com/groups/opt_out.
