Use the same controller for publishing cards and for publishing and adding another
This commit is contained in:
@@ -3,6 +3,12 @@ class Cards::PublishesController < ApplicationController
|
||||
|
||||
def create
|
||||
@card.publish
|
||||
redirect_to @card
|
||||
|
||||
redirect_to add_another_param? ? @collection.cards.create! : @card
|
||||
end
|
||||
|
||||
private
|
||||
def add_another_param?
|
||||
params[:creation_type] == "add_another"
|
||||
end
|
||||
end
|
||||
|
||||
@@ -15,11 +15,6 @@ class CardsController < ApplicationController
|
||||
end
|
||||
|
||||
def create
|
||||
if params[:publish_current]
|
||||
@card = Card.find(params[:publish_current])
|
||||
@card.publish
|
||||
flash[:notice] = "Card added"
|
||||
end
|
||||
card = @collection.cards.create!
|
||||
redirect_to card
|
||||
end
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
<div class="card-perma__notch card-perma__notch--bottom">
|
||||
<%= button_to "Create card", card_publish_path(card), class: "btn" %>
|
||||
<%= button_to "Create and add another", collection_cards_path(card.collection, publish_current: card.id), method: :post, class: "btn btn--reversed", form: { data: { turbo: false } } %>
|
||||
<%= button_to "Create card", card_publish_path(card), name: "creation_type", value: "add", class: "btn" %>
|
||||
<%= button_to "Create and add another", card_publish_path(card), method: :post, class: "btn btn--reversed", name: "creation_type", value: "add_another", form: { data: { turbo: false } } %>
|
||||
<%= button_to "Save as a draft", collection_card_path(card.collection, card), name: "card[status]", value: "drafted", method: :put, class: "btn btn--reversed" %>
|
||||
</div>
|
||||
|
||||
Reference in New Issue
Block a user