ruby-on-railsrubyflashwicked-gem

Rails Wicked Gem - Flash Messages


I have a Campaign model and I am using Wicked Gem for step by step campaign creation.

I have total 3 steps in the wizard...

steps :details, :audiance, :creatives

Here is my Wizard controller

class Brands::CampaignWizardsController < Brands::ApplicationController
  include Wicked::Wizard
  steps :details, :audiance, :creatives

  def show
    @campaign = current_company.campaigns.friendly.find(params[:campaign_id])
    render_wizard
  end

  def update
    case step
      when :details
        @campaign.attributes = campaign_details_params

        @campaign[:dos].delete_if(&:blank?)
        @campaign[:donts].delete_if(&:blank?)

        @campaign_ideas = CampaignIdea.where(objective_id: @campaign.objective_id)

      when :audiance
        @campaign.attributes = campaign_audiance_params

        @campaign[:influencer_interests].delete_if(&:blank?)

      when :creatives
        @campaign.attributes = campaign_creatives_params

    end
    render_wizard @campaign
  end
end

I would like to add flash messages (success/error) in each step of the wizard.

Is there any way to pass my messages as an option{} to render_wizard ?


Solution

  • You should be able to achieve this with: flash[:notice] = "Campaign successfully updated.