Refactor name condition to a cleaner code, delegate :full_name from profile to person to user

This commit is contained in:
flaburgan 2017-07-19 10:49:47 +02:00
parent c2e0feb38b
commit 9a27983313
3 changed files with 3 additions and 5 deletions

View file

@ -22,7 +22,7 @@ class Person < ActiveRecord::Base
end
has_one :profile, dependent: :destroy
delegate :last_name, :image_url, :tag_string, :bio, :location,
delegate :last_name, :full_name, :image_url, :tag_string, :bio, :location,
:gender, :birthday, :formatted_birthday, :tags, :searchable,
:public_details?, to: :profile
accepts_nested_attributes_for :profile

View file

@ -46,7 +46,7 @@ class User < ActiveRecord::Base
delegate :guid, :public_key, :posts, :photos, :owns?, :image_url,
:diaspora_handle, :name, :atom_url, :profile_url, :profile, :url,
:first_name, :last_name, :gender, :participations, to: :person
:first_name, :last_name, :full_name, :gender, :participations, to: :person
delegate :id, :guid, to: :person, prefix: true
has_many :aspects, -> { order('order_id ASC') }

View file

@ -1,8 +1,6 @@
<%= t('.message',
invite_url: invite_code_url(@invitation_code),
diasporafoundation_url: 'https://diasporafoundation.org/',
user: @inviter.try(:diaspora_handle) == @inviter.try(:name) ?
@inviter.try(:diaspora_handle) :
@inviter.try(:name) + " (" + @inviter.try(:diaspora_handle) + ")",
user: @inviter.try(:full_name).empty? ? @inviter.try(:diaspora_handle) : "#{@inviter.name} (#{@inviter.diaspora_handle})",
diaspora_id: @inviter.try(:diaspora_handle))
%>