bin/rails g controller my_campaigns
resources :my_campaigns, only: [:index]
<%=link_to "My projects", my_campaigns_path%>
before_action :authernticate_user
def index @campaigns = current_user.campaigns end
bin/rails g controller publishings
insdie the campaigns routes resources :publishing, only: [:create]
<% if @campaign.draft? %> <%= link_to "Publish", campaign_publishings_path(@campaign), method: :post,class: "btn btn-primary", data: {confirm: "Are you sure? you wont be able to edit the campaign after it's published."}%> <% end %>
in the publishings controller before_action :authenticate_user!
def create campaign = current_user.campaigns.friendly.find params[:campaign_id] if campaign.publish! redirect_to campaign, notice: "Published!" else redirect_to campaign, alert: "Can't publish!" end