Files
grecia/app/components/admin/budgets/table_actions_component.rb
Javi Martín 6a2c01b119 Extract method to render an admin table action
This way it will be easier to change the behavior of all table actions,
like adding ARIA attributes. In the past, when we changed the behavior
of the `link_to` method, we had to change all table action classes.
2021-09-20 20:27:37 +02:00

21 lines
455 B
Ruby

class Admin::Budgets::TableActionsComponent < ApplicationComponent
attr_reader :budget
def initialize(budget)
@budget = budget
end
private
def create_budget_poll_path
balloting_phase = budget.phases.find_by(kind: "balloting")
admin_polls_path(poll: {
name: budget.name,
budget_id: budget.id,
starts_at: balloting_phase.starts_at,
ends_at: balloting_phase.ends_at
})
end
end