On Jul 21, 2012, at 12:19 AM, Avantec Van wrote:

> Walter Davis wrote in post #1065538:
> 
> 
>>  match '/:slug', :to => 'uploaded_files#show'
>> 
>> That should do the trick.
>> 
>> Here's a way to make a very terse code for your URL:
>> 
>>  def set_slug
>>    code = Array.new(7) { (('A'..'Z').to_a + (0..9).to_a)[rand(36)]
>> }.join.to_s
>>    if UploadedFile.find_by_slug(code)
>>      return self.set_slug()
>>    else
>>      self.slug = code
>>    end
>>  end
>> 
>> Call it in an after_create.
>> 
>> Walter
> 
> Thanks a lot. It is working :) cheers….

Glad it works for you!

Walter

-- 
You received this message because you are subscribed to the Google Groups "Ruby 
on Rails: Talk" group.
To post to this group, send email to rubyonrails-talk@googlegroups.com.
To unsubscribe from this group, send email to 
rubyonrails-talk+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.


Reply via email to