草庐IT

face_file_name

全部标签

ruby LoadError : cannot load such file

例如,当我需要一个文件(称为st.rb)时:require'rubygems'require'mongrel'classTestHandler在irb中我得到:>>require'st.rb'LoadError:cannotloadsuchfile--st.rbfrom/usr/local/lib/ruby/1.9.1/rubygems/custom_require.rb:36:in`require'from/usr/local/lib/ruby/1.9.1/rubygems/custom_require.rb:36:in`require'from(irb):3from/usr/loc

ruby-on-rails - 为什么 Ruby "script/generate"返回 "No such file or directory"?

我在使用script/generate时遇到问题。我正在关注treebasednavigation教程,它说使用script/plugininstallgit://github.com/rails/acts_as_tree.git或script/generatenifty_layout。我不断得到:Nosuchfileordirectory--script/plugin我试过这些变体:script/generatenifty_layoutrailsgeneratenifty_layoutrubyscript/generatenifty_layoutrubygeneratenifty_l

ruby-on-rails - Rails 4 + Devise : Invalid route name, 已在使用中

我正在按照此操作方法在成功注册后修改确认页面。https://github.com/plataformatec/devise/wiki/How-To:-Redirect-to-a-specific-page-on-successful-sign-up-(registration)我按照它所说的做了所有事情,但我得到了这个错误:in`add_route':Invalidroutename,alreadyinuse:'new_user_session'(ArgumentError)Youmayhavedefinedtworouteswiththesamenameusingthe`:as`o

关于Document mapping type name can‘t start with ‘_‘, found: [_update]

在修改elasticsearch时,用_update进行局部修改,修改失败,报错{    "error": {        "root_cause": [            {                "type": "invalid_type_name_exception",                "reason": "Document mapping type name can't start with '_', found: [_update]"            }        ],        "type": "invalid_type_name_exce

ruby - 冒号(:) appears as forward slash (/) when creating file name

我正在使用日期和时间来标记我正在创建的新文件,但是当我查看该文件时,冒号是一个正斜杠。我正在使用10.7+在Mac上开发这是我使用的代码:File.open("#{time.hour}:00,#{time.month}-#{time.day}-#{time.year}","a")do|mFile|mFile.syswrite("#{pKey}-#{tKey}:\n")mFile.syswrite("Itemsclosed:#{itemsClosed}|Totalitems:#{totalItems}|Percentclosed:%#{pClosed}\n")mFile.syswrite

ruby - File.open 带 block vs 不带

我有一个关于Block的问题,这两个代码的意思一样吗?代码1File::open('yozloy.txt','w')do|f|f代码2newFile=File::open('yozloy.txt','w')newFile 最佳答案 不,它们的意思不同。在第一个示例中,文件在处理完block后自动关闭。在第二个示例中,您有责任手动调用newFile.close。 关于ruby-File.open带blockvs不带,我们在StackOverflow上找到一个类似的问题:

ruby-on-rails - bcrypt 加载错误 : Cannot load such file

我正在尝试为我的Rails应用程序设置登录功能,当我按下登录按钮时,我收到一条bcrypt错误消息:LoadErrorinSessionsController#createcannotloadsuchfile--bcrypt还有其他人遇到这个错误吗?我有最新版本的bcrypt,我完全按照教程告诉我的去做。用户模型:我在据称错误所在的行周围加上了星号。classUsersessionController:classSessionsController应用程序Controller:classApplicationControllersession助手:moduleSessionsHelpe

ruby - File.join 什么时候有用?

通过阅读文档,很明显File.join将给定参数与/字符连接起来。与filenames.join('/')相比,什么时候使用它有益? 最佳答案 还有一个细微的区别:File.join('foo','bar')#=>"foo/bar"['foo','bar'].join('/')#=>"foo/bar"但是,如果您传递一个已经以/结尾的参数(这在处理路径时很常见),您将不会在结果中有两个斜线:File.join('foo/','bar')#=>"foo/bar"['foo/','bar'].join('/')#=>"foo//bar"

ruby-on-rails - rails : Testing named scopes with RSpec

我是测试Rails网络应用程序和RSpec的新手。我使用遗留代码并需要添加测试。那么使用RSpec测试查找器和命名范围的最佳方法是什么?我在Google中找到了一些方法,但它们并不理想。例如:http://paulsturgess.co.uk/articles/show/93-using-rspec-to-test-a-named_scope-in-ruby-on-railsit"excludesusersthatarenotactive"do@user=Factory(:user,:active=>false)User.active.should_notinclude(@user)e

ruby-on-rails - 在 Ruby on Rails 中,send_file 方法后从服务器删除文件

我正在使用以下代码在Rails中发送文件。ifFile.exist?(file_path)send_file(file_path,type:'text/excel')File.delete(file_path)end在这里,我尝试发送文件并在成功发送后从服务器中删除文件。但我面临的问题是,在执行发送时删除操作正在执行,因此我在浏览器中看不到任何内容。那么在Rails中有没有什么办法,一旦send_file操作完成就从服务器上删除文件。如有任何帮助,我们将不胜感激。谢谢,切坦 最佳答案 因为您正在使用send_file,Rails会将