【发布时间】:2015-07-12 17:24:47
【问题描述】:
不确定我是否以正确的方式进行此操作,但我的模型中有以下内容,并希望在我的视图中呈现它(即显示剩余的开放学生空间的数量)
型号:
def open_student_spots
event.student_rsvp_limit - event.student_rsvps_count
end
这是我试图在我的视图中显示的区域,这是我所做的(尽管到目前为止不正确)
<i class='fa fa-user'></i>Spaces Available: <%=
<% if event.students_at_limit? %>
(<%= event.student_waitlist_rsvps_count %> Waitlisted)
<% else %>
<% open_student_spots %> #how to fix this line?
</div>
<% end %>
请问我该怎么做?
【问题讨论】:
-
我觉得这是错误的
event.student_rsvp_limit - event.student_rsvps_count。
标签: ruby-on-rails ruby-on-rails-4 model-view-controller