# -*- encoding : utf-8 -*- class PetitionsController < ApplicationController before_filter :authenticate_admin! def show @petition = Petition.find_by_slug(params[:id]) @signator = @petition.signators.new(:country => "France") @title = "Le Pic Vert - "+@petition.name end def new @petition = Petition.new end def edit @petition = Petition.find(params[:id]) end def create @signator = PetitionSignator.new(params[:petition_signator]) @petition = @signator.petition @title = "Le Pic Vert - "+@petition.name if @signator.save PetitionMails.confirmation(@signator).deliver render action: "create" else render action: "show" end end def confirm @signator = PetitionSignator.find_by_token(params[:id]) @petition = @signator.petition @title = "Le Pic Vert - "+@petition.name @signator.enabled = true @signator.save! end end