Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Displayed the missing attributes of model person in the edit and show…

… view.
  • Loading branch information...
commit 93ae50e3018430c8e4b874d75c16dc85ca5e9ab4 1 parent 2048fe8
@raskhadafi raskhadafi authored
View
8 app/models/person.rb
@@ -13,6 +13,10 @@ class Person < ActiveRecord::Base
validates_date :date_of_birth, :date_of_death, :allow_nil => true, :allow_blank => true
validates_presence_of :vcard
+ def self.gender
+ [[I18n.t('activerecord.values.person.male'), MALE], [I18n.t('activerecord.values.person.female'), FEMALE]]
+ end
+
# Constructor
def initialize(attributes = nil)
super
@@ -26,6 +30,10 @@ def to_s
"%s (%s)" % [vcard.try(:full_name), vcard.try(:locality)]
end
+ def sex_to_s
+ sex.eql?MALE ? I18n.t('activerecord.values.person.male') : I18n.t('activerecord.values.person.female')
+ end
+
# Tags
acts_as_taggable
View
12 app/stylesheets/partials/content/_ui_tabbs.sass
@@ -1,5 +1,9 @@
-#tab-form_address,
-#tab-form_remarks,
-#tab-form_user
+#tabs
form.formtastic
- border: none
+ border: none
+
+#tab-form_address
+ form.formtastic .date label
+ display: block
+ form.formtastic li fieldset .label
+ margin-top: 20px
View
3  app/views/people/_form.html.haml
@@ -1,5 +1,8 @@
= semantic_form_for resource do |f|
= f.semantic_errors
+ = f.input :date_of_birth
+ = f.input :date_of_death
+ = f.input :sex, :as => :select, :collection => Person.gender
= f.inputs t('form.person.address') do
= render 'vcards/form', :f => f
View
14 app/views/people/_tab_address.html.haml
@@ -1,5 +1,19 @@
= render 'people/tab_header'
+- [:date_of_birth, :date_of_death].each do |attr|
+ - if resource.send(attr)
+ %h2
+ = t("activerecord.attributes.person.#{attr}")
+ %p
+ = resource.send(attr)
+ %br
+- if resource.sex
+ %h2
+ = t("activerecord.attributes.person.sex")
+ %p
+ = resource.sex_to_s
+ %br
+
%h2
= t('learnyt.address')
= full_address(resource.vcard)
View
3  app/views/people/_tab_create_user.html.haml
@@ -1,4 +1,5 @@
-= render 'people/tab_header'
+%h1
+ = resource
%h2
= t_title(:new, User)
View
5 config/locales/learnyt.de.yml
@@ -126,6 +126,11 @@ de:
body: Inhalt
send_at: Versandzeit
+ values:
+ person:
+ male: Mann
+ female: Frau
+
learnyt:
all: Alle
edit: Editieren
Please sign in to comment.
Something went wrong with that request. Please try again.