在ruby 2.2.0中你可以写这样的哈希:
hash = { 'new_possible_style': :of_hashes }
hash[:new_possible_style] #=> :of_hashes
hash['new_possible_style'] #=> nil
Run Code Online (Sandbox Code Playgroud)
我无法意识到实现这种风格的原因.如果我需要字符串作为键(例如,对于某些第三方库),我仍然需要使用旧式哈希.这个"功能"的用例是什么?核心开发人员为什么要添加这种风格?
提前致谢.
我已经在谷歌驱动器上完成文件上传,但在下载时遇到错误:
ActionController::MissingFile: Cannot read file original_22_Wages372-817339(wages).pdf
Run Code Online (Sandbox Code Playgroud)
我认为它没有得到谷歌驱动器路径.
附件模型:
has_attached_file :doc,
storage: :google_drive,
google_drive_credentials: "#{Rails.root}/config/google_drive.yml",
google_drive_options: {
public_folder_id: '0BwCp_aK6VhiaQmh5TG9Qbm0zcDQ',
path: proc { |style| "#{style}_#{id}_#{doc.original_filename}" }
}
Run Code Online (Sandbox Code Playgroud)
控制器:
attachment = Attachment.find(params[:id])
send_file attachment.doc.path(:original),
filename: attachment.doc_file_name,
type: attachment.doc_content_type,
stream: 'true',
x_sendfile: true
Run Code Online (Sandbox Code Playgroud)
提前致谢
当我按ctrl + b运行简单的代码,如:
puts "asdasd"
Run Code Online (Sandbox Code Playgroud)
结果是空白字段.Ruby路径是/home/yukke/.rvm/rubies/default/bin/ruby和ruby -v => ruby 1.9.3p194(2012-04-20 revision 35410)[x86_64-linux].
所以我试着改变Ruby.sublime-build
{
"cmd": ["/home/yukke/.rvm/rubies/default/bin/ruby", "-u","$file"],
"file_regex": "^(...*?):([0-9]*):?([0-9]*)",
"selector": "source.ruby"
}
Run Code Online (Sandbox Code Playgroud)
但它没有改变任何东西.请帮我解决这个问题.