You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
includeAASM# setting the whiny_transitions: false option makes it so that it won't# throw an exception when an invalid transition happenaasmwhiny_transitions: falsedostate:draft,initial: truestate:publishedstate:unfundedstate:fundedstate:canceledevent:publishdotransitionsfrom: :draft,to: :publishedendevent:canceldotransitionsfrom: [:draft,:published,:funded],to: :canceledendevent:funddotransitionsfrom: :published,to: :fundedendevent:unfunddotransitionsfrom: :published,to: :unfundedendend
set the transition state
2.2.3 :008 > c.draft?true
2.2.3 :009 > c.published?false
2.2.3 :010 > c.published!
(0.2ms) BEGIN
Campaign Exists (0.4ms) SELECT 1 AS one FROM "campaigns" WHERE ("campaigns"."name" = 'Hello try reward' AND "campaigns"."id"!= 8) LIMIT 1
SQL (0.3ms) UPDATE "campaigns" SET "aasm_state" = $1, "updated_at" = $2 WHERE "campaigns"."id" = $3 [["aasm_state", "published"], ["updated_at", "2016-03-16 20:44:09.409139"], ["id", 8]]
FriendlyId::Slug Load (0.2ms) SELECT "friendly_id_slugs".* FROM "friendly_id_slugs" WHERE "friendly_id_slugs"."sluggable_id" = $1 AND "friendly_id_slugs"."sluggable_type" = $2 ORDER BY "friendly_id_slugs".id DESC LIMIT 1 [["sluggable_id", 8], ["sluggable_type", "Campaign"]]
(1.3ms) COMMIT
true
2.2.3 :011 >
only show campaigns that are published on the index page
add a button on campaign show page which will publish this campaign
<% if @campaign.draft? %><%= link_to "Publish", campaign_publishing_path(@campaign), method: :post, class: "btn btn-primary", data: {confirm: "are you sure? you won't be able to edit a campaign after it's pubhlished"} %><% end %>