def create_contribution

      @initiative = Initiative.find(contribution_params[:initiative_id])
      @gateways = @initiative.gateways.without_state(:draft).ordered
      @contribution = @initiative.contributions.new(contribution_params)
      @contribution.gateway_state = @contribution.gateway.state
      current_user.update module_name: @contribution.gateway.module_name
      authorize @contribution

      if @contribution.save
        true
      else
        render '/initiatives/contributions/new'
        false
      end

    end
def create_contribution

      @initiative = Initiative.find(contribution_params[:initiative_id])
      @gateways = @initiative.gateways.without_state(:draft).ordered
      @contribution = @initiative.contributions.new(contribution_params)
      @contribution.gateway_state = @contribution.gateway.state
      current_user.update module_name: @contribution.gateway.module_name
      authorize @contribution

      if @contribution.save
        true
      else
        render '/initiatives/contributions/new'
        false
      end

    end
Creates the contribution, sets session[:gateway_id], returns true if successful and renders new action if not