Files
grecia/app/components/admin/budgets/table_actions_component.rb
Javi Martín 02e27e13dc Extract component for budget actions
We can omit passing a parameter to the helper method thanks to that, and
we group related code together.
2020-10-21 13:19:52 +02:00

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