I have a Product model which has several columns out of which two columns are :first_name and :last_name.
How would I parameterize value of column B(:last_name) when the value of column A(:first_name) is absent or blank.
I tried two methods below and it did not work.
def to_param
if :first_name.present?
"#{id}-#{first_name.parameterize}"
else
"#{id}-#{last_name.parameterize}"
end
Method-2:
def to_param
"#{id}-#{first_name.parameterize}" || "#{id}-#{last_name.parameterize}"
end