Rails -- filename去除扩展名

简单例子:params[:upload]['preview'].original_filename 的值为templateOne.html.erb
 template_name = File.basename(params[:upload]['preview'].original_filename, ".html.erb").to_s

获得的template_name的值为templateOne。

04-14 16:06