app/models/picture.rb
# Define the permalink. Test if this permalink is already use.
# if it already use add a -#{index} after
Define the permalink. Test if this permalink is already use.
if it already use add a -#{index} after
Define the permalink . Test if this permalink is already use . if it already use add a - # { index } after
def define_permalink
    self.permalink = title.downcase.gsub(/[^a-z0-9]+/i, '-')
    permalink_insert = self.permalink
    i = 1
    while !Picture.find_by_permalink(permalink_insert).nil? || ensure_permalink_is_not_a_route(permalink_insert) do
      permalink_insert = "#{self.permalink}-#{i}"
      i = i + 1
    end
    self.permalink = permalink_insert
  end
def define_permalink self . permalink = title . downcase . gsub ( / [^a-z0-9]+ /i , '-' ) permalink_insert = self . permalink i = 1 while ! Picture . find_by_permalink ( permalink_insert ) . nil? || ensure_permalink_is_not_a_route ( permalink_insert ) do permalink_insert = "#{self.permalink}-#{i}" i = i + 1 end self . permalink = permalink_insert end
Define the permalink.
Define the permalink .