I am using the wicked gem for a wizard form. In one of the steps of my form I have fields to upload attachments. I'm using active storage and Rails 6.
In my view
<%= f.file_field :plan %>
<%= f.file_field :appraisal %>
<%= f.file_field :flow %>
In my sale_steps controller
def show
@sale = current_user.sales.find(params[:sale_id])
render_wizard
end
def update
@sale = current_user.sales.find(params[:sale_id])
params[:sale][:status] = step.to_s **(the error is on this line)**
@sale.update(sale_params)
render_wizard @sale
end
def sale_params
params.require(:sale).permit(.... :plan, :appraisal, :flow)
end
In my model
has_one_attached :plan
has_one_attached :appraisal
has_one_attached :flow
validates :location, presence: true, if: -> { status?(:second_step) }
def status?(step_key)
status == step_key.to_s (this is to allow validations on each step - I have no validations defined for my attachments)
end
In my form when I reach the last step of the wizard to upload attachments it works fine so long as at least one of the attachments are present. However, if no attachments are present I get the following no method error on update click:
undefined method `[]=' for nil:NilClass
{"_method"=>"put", "authenticity_token"=>"[FILTERED]", "commit"=>"Continue", "sale_id"=>"37", "id"=>"fourth_step"}
I'm just wondering why this might be (is it something to do with the wicked gem or something else?) and is there a solution I can try? ty