简体   繁体   中英

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 ?

您应该可以通过以下方式实现此目的: flash[:notice] = "Campaign successfully updated

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM