I'm using Rails 4 and trying to display a currency and amount in my show page.
I have a model which has expenses, currency and participation_cost attributes. Expenses is a boolean. If true, then the currency and the expenses should be displayed.
If a project cost has participation expenses, I'd like to display the amount followed by the currency, as follows:
<% if @project.scope.try(:participant).try(:expenses) == true %>
<%= "#{@project.scope.try(:participant).try(:participation_cost)} #{@project.scope.try(:participant).try(:currency)}" %>
<% else %>
<%= render :text => "Participants do not receive participation costs or payment" %>
However, the output of this is only the number for participant costs, without the currency indicator. The database has a currency stored.
Project model has:
class Project < ActiveRecord::Base
include RoleModel
# --------------- associations
#belongs_to :students, through: :courses, counter_cache: true
has_many :project_questions#, through: :projects
has_many :project_answers#, through: :project_questions
has_one :scope
accepts_nested_attributes_for :scope
has_one :educator_project_comment
has_many :project_student_eois
belongs_to :educator
has_many :project_invitations
has_many :observations
has_one :approval
belongs_to :industry
has_and_belongs_to_many :users
mount_uploader :hero_image, AvatarUploader
mount_uploader :link_to_video_proposal, VideoUploader
# --------------- scopes
Can anyone see what I've done wrong?
Thank you
Project
model. – potashinparticipant.currency
in#{@project.scope.try(:participant).try(:currency)
. Does each participant keep track of its owncurrency
? – fylooi