0

I have an Application.rb that

belongs_to :company

and the Company.rb can

has_many :applications

I've set up friendly_id on the Company model but also want it on my application. But the Application doesn't store what I want as slug_candidates. I want slug candidates to be taken from the Company the application belongs to.

This is my Applicatio.rb

extend FriendlyId
 friendly_id :slug_candidates, use: [:slugged, :history]

def slug_candidates
 [
  :intern_type,
  [:intern_type, Company.city]
 ]
end

how would I set it up so it gets that it should take it from the Company?

strivedi183
  • 4,749
  • 2
  • 31
  • 38
user2755537
  • 151
  • 1
  • 9

1 Answers1

0

I think that you should be able to do in Application model,

def slug_candidates
  [
    :intern_type,
    [:intern_type, company.city]
  ]
end

I think that this stack overflow question has a similar issue.

Hope this helps!

Community
  • 1
  • 1
strivedi183
  • 4,749
  • 2
  • 31
  • 38