I am using the Wicked gem to create an object in multiple steps. Everything seemed to be working fine until I realized that the data was not saving. I noticed it was not saving whenever url: wizard_path
was present in the form builder. When that is not there, the data saves just fine, no matter which step I am on. This is what my controller for the object builder looks like:
class Bids::BuildController < ApplicationController
include Wicked::Wizard
steps :intro, :problems, :solutions, :pricing
def show
@bid = Bid.find(params[:bid_id])
render_wizard
end
def create
@bid = Bid.new(bid_params)
redirect_to wizard_path(steps.first, :bid_id => @bid.id)
end
def update
@bid = Bid.find(params[:bid_id])
params[:bid][:status] = 'active' if step == steps.last
@bid.attributes = params[:bid].permit(:bid_attribute)
render_wizard @bid
end
# GET /bids/new
def new
@bid = Bid.new
redirect_to wizard_path(steps.first, :bid_id => @bid.id)
end
end
You mentioned in your comment that you are permitting params in the bid controller. Add them to your build controller. Since you are building your object in this controller, it needs to have access to the permitted params.
Add:
def build_params
params.require(:bid).permit(:param_1,:param_2,:param_3,:etc)
end
to your bids/build_controller.rb