Commit ee2fe030 authored by Kaspar Vollenweider's avatar Kaspar Vollenweider 👻 Committed by Kaspar
Browse files

temp commit with first_language

parent 82eceaa0
......@@ -8,7 +8,8 @@ module VolunteerAttributes
:profession, :education, :motivation, :experience, :expectations,
:strengths, :skills, :interests, :state, :duration, :man, :woman,
:family, :kid, :sport, :creative, :music, :culture, :training,
:german_course, :adults, :teenagers, :children, :region, :state
:german_course, :adults, :teenagers, :children, :region, :state,
:first_language, :title, first_language_attributes: [:id, :language]
]
end
end
......
......@@ -22,6 +22,8 @@ class VolunteersController < ApplicationController
def create
@volunteer = Volunteer.new(volunteer_params)
@volunteer.schedules << Schedule.build
@volunteer.build_contact
authorize @volunteer
if @volunteer.save
redirect_to @volunteer, notice: t('volunteer_created')
......
......@@ -2,6 +2,7 @@ class Contact < ApplicationRecord
belongs_to :contactable, polymorphic: true, optional: true
validates :last_name, presence: true, if: :department?
validates :first_name, :last_name, presence: true, if: :volunteer?
has_many :contact_emails
accepts_nested_attributes_for :contact_emails, allow_destroy: true
......@@ -19,4 +20,8 @@ class Contact < ApplicationRecord
def department?
contactable_type == 'Department'
end
def volunteer?
contactable_type == 'Volunteer'
end
end
class FirstLanguage < LanguageSkill
end
......@@ -4,6 +4,7 @@ class Volunteer < ApplicationRecord
has_one :contact, as: :contactable
accepts_nested_attributes_for :contact
has_one :first_language
acts_as_paranoid
......
......@@ -30,6 +30,10 @@
.col-xs-12.col-md-6
= f.input :additional_nationality, as: :country
= f.simple_fields_for :first_language do |language|
.col-xs-12.col-md-6
= language.input :language, collection: languages, label: t_attr(:first_language)
= render 'language_skills/form', f: f, speaker: @volunteer
.row
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment