Files
nairobi/app/helpers/followables_helper.rb
Javi Martín 66759d2dc0 Apply StringConcatenation rule in some places
This rule was added in Rubocop 0.89.0. However, there are some false
positives when we don't use interpolation but simply concatenate in
order to avoid long lines. Even if there weren't false positives, there
are places where we concatenate to emphasize the point that we're adding
a certain character to a text.

We might reconsider this rule in the future, since we generally prefer
interpolation over concatenation.
2020-10-23 12:01:39 +02:00

31 lines
780 B
Ruby

module FollowablesHelper
def followable_type_title(followable_type)
t("activerecord.models.#{followable_type.underscore}.other")
end
def followable_icon(followable)
{
proposals: "Proposal",
budget: "Budget::Investment"
}.invert[followable]
end
def render_follow(follow)
return unless follow.followable.present?
followable = follow.followable
partial = "#{followable_class_name(followable)}_follow"
locals = { followable_class_name(followable).to_sym => followable }
render partial, locals
end
def followable_class_name(followable)
followable.class.to_s.parameterize(separator: "_")
end
def find_or_build_follow(user, followable)
Follow.find_or_initialize_by(user: user, followable: followable)
end
end