We were using a redundant `elsif` instead of an `else`. We were also using a negative condition in the main `if`, which made the code a bit harder to read. Since we usually use `current_user` instead of `user_signed_in?`, we're also changing that for consistency.Extract component to render the status of a poll
19 lines
418 B
Ruby
19 lines
418 B
Ruby
class Polls::PollComponent < ApplicationComponent
|
|
attr_reader :poll
|
|
use_helpers :cannot?, :current_user, :link_to_poll
|
|
|
|
def initialize(poll)
|
|
@poll = poll
|
|
end
|
|
|
|
private
|
|
|
|
def dates
|
|
if poll.starts_at.blank? || poll.ends_at.blank?
|
|
I18n.t("polls.no_dates")
|
|
else
|
|
I18n.t("polls.dates", open_at: l(poll.starts_at.to_date), closed_at: l(poll.ends_at.to_date))
|
|
end
|
|
end
|
|
end
|