Sha256: dcd4a7b5808594f212c0fb4ca2a7d4af9972ab771356721dfe903ae970226aab

Contents?: true

Size: 933 Bytes

Versions: 3

Compression:

Stored size: 933 Bytes

Contents

module Refinery
  module RaceRegistrations
    class PeopleController < ::ApplicationController
      before_filter :find_page

      def new
        @person = Person.new
        @registrations = Registration.published
        @categories = @registrations.first.try(:categories)

        present(@page)
      end

      def create
        @person =   Person.new(params[:person])

        if @person.save
          redirect_to refinery.race_registrations_registration_path(:id=> @person.registration_id) , :notice => t('refinery.crudify.created', :what => @person.name + " " + @person.surname )
        else
          @registrations = Registration.published
          @categories = @registrations.first.try(:categories)

          render :action=> "new"
        end
      end


      protected

      def find_page
        @page = Refinery::Page.where(:link_url => "/race_registrations/people/new").first
      end

    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
refinerycms-registrations-0.1.2 app/controllers/refinery/race_registrations/people_controller.rb
refinerycms-registrations-0.1.1 app/controllers/refinery/race_registrations/people_controller.rb
refinerycms-registrations-0.1.0 app/controllers/refinery/race_registrations/people_controller.rb