Ruby
Before/After String Logic
friendly_url = @object.id.to_s
name = unimportant_dasherize_method(@object.name)
unless name.blank?
if trailing_id_binary_flag
friendly_url = name << "-#{friendly_url}"
else
friendly_url << "-#{name}"
end
end
friendly_url = @object.id.to_s
name = unimportant_dasherize_method(@object.name)
unless name.blank?
if trailing_id_binary_flag
friendly_url = name << "-#{friendly_url}"
else
friendly_url << "-#{name}"
end
end
Refactorings
No refactoring yet !
December 18, 2010,
December 18, 2010 00:07,
permalink
2 ratings.
Login to rate!
name = unimportant_dasherize_method(@object.name) # fix this to return nil rather than blank
array = [@object.id.to_s, name].compact
array.reverse! if trailing_id_binary_flag
friendly_url = array.join('-')
Looking for a less cumbersome way to add an record id to either the front or back of a friendly_url depending upon a flag value.