Ruby: Get filename without the extensions

Read documentation:

basename(file_name [, suffix] ) → base_name

Returns the last component of the filename given in file_name, which
can be formed using both File::SEPARATOR and File::ALT_SEPARATOR as
the separator when File::ALT_SEPARATOR is not nil. If suffix is given
and present at the end of file_name, it is removed.

=> File.basename('public/500.html', '.html')
=> "500"

in you case:

=> File.basename("test.html.erb", ".html.erb")
=> "test"

Leave a Comment

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)