How do I the dot when getting the file extension name in rails?
Right now I'm using File.extname
but it's keeping the "." before giving me the name
Would this work for you?
File.extname('something.jpg').delete('.') #=> 'jpg'
You could even wrap it up in a helper:
def file_extension(filename)
File.extname(filename).delete('.')
end
file_extension('something.jpg') #=> 'jpg'
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With