We can omit passing a parameter to the helper method thanks to that, and we group related code together.
22 lines
531 B
Ruby
22 lines
531 B
Ruby
class Admin::Budgets::TableActionsComponent < ApplicationComponent
|
|
attr_reader :budget
|
|
|
|
def initialize(budget)
|
|
@budget = budget
|
|
end
|
|
|
|
private
|
|
|
|
def link_to_create_budget_poll
|
|
balloting_phase = budget.phases.find_by(kind: "balloting")
|
|
|
|
link_to t("admin.budgets.index.admin_ballots"),
|
|
admin_polls_path(poll: {
|
|
name: budget.name,
|
|
budget_id: budget.id,
|
|
starts_at: balloting_phase.starts_at,
|
|
ends_at: balloting_phase.ends_at }),
|
|
method: :post
|
|
end
|
|
end
|