0

When I create a new Invoice in my Rails program friendly_id is updating the history with the new slug. What do I need to do to fix this issue.

Currently I have no idea how to fix this in my program.

extend FriendlyId
  friendly_id :slug_candidates, use: %i[history slugged finders scoped], scope: :educator_id

I used above to import history and slugged. I also added the following method for creating the Invoice numbers of a slug

def slug_candidates
    # TODO: check what happens if you have 2 educators with same invoice number
    [:number, %i[number id]]
end

def should_generate_new_friendly_id?
    slug.blank? || number_changed?
end
Stefan
  • 61
  • 6
  • Why not just nest the resource IE. `/educators/john_doe/invoices/1`? – max Aug 13 '18 at 13:23
  • What does your `number_changed?` method look like? Where is your `should_generate_new_friendly_id?` method called? – Beengie Sep 25 '18 at 18:51

0 Answers0