草庐IT

file_system

全部标签

ruby-on-rails - rails : Your user account isn't allowed to install to the system RubyGems

我正在运行命令bundleinstall在项目文件夹中。在某些项目文件夹中,它会产生错误,而在其他项目文件夹中,它不会产生错误。错误是:Youruseraccountisn'tallowedtoinstalltothesystemRubyGems我知道这可以通过遵循推荐的建议来解决:bundleinstall--pathvendor/bundle我的问题是为什么行为不一致? 最佳答案 在我的例子中,我按照错误消息的建议解决了问题:Youruseraccountisn'tallowedtoinstalltothesystemRubyG

ruby-on-rails - 在 `require' : no such file to load -- iconv (LoadError)

➜expertizagit:(master)✗ruby-vruby1.8.7(2011-06-30patchlevel352)[i686-darwin11.1.0]➜expertizagit:(master)✗rails-vRails2.3.14➜expertizagit:(master)✗script/server/Users/HPV/.rvm/gems/ruby-1.8.7-p352/gems/activesupport-2.3.14/lib/active_support/inflector.rb:3:in`require':nosuchfiletoload--iconv(Load

ruby - 使用 WWW :Mechanize to download a file to disk without loading it all in memory first

我正在使用Mechanize来简化某些文件的下载。目前我的脚本使用以下行来实际下载文件...agent.get('http://example.com/foo').save_as'a_file_name'然而,这会将完整的文件下载到内存中,然后再将其转储到磁盘。你如何绕过这种行为,直接下载到磁盘?如果我需要使用WWW:Mechanize以外的东西,那么我将如何使用WWW:Mechanize的cookies呢? 最佳答案 您真正想要的是Mechanize::Downloadhttp://mechanize.rubyforge.org/

ruby-on-rails - ruby rails : How do you check if a file is an image?

如何检查文件是否为图像?我想你可以使用这样的方法:defimage?(file)file.to_s.include?(".gif")orfile.to_s.include?(".png")orfile.to_s.include?(".jpg")end但这可能有点低效而且不正确。有什么想法吗?(我正在使用回形针插件,顺便说一句,但我没有看到任何方法来确定文件是否是回形针中的图像) 最佳答案 请检查一次MIME::Types.type_for('tmp/img1.jpg').first.try(:media_type)=>"image"

ruby-on-rails - Rails + Twitter Bootstrap : File to import not found or unreadable: twitter/bootstrap

我正在尝试使用TwitterBootstrap(gemtwitter-bootstrap-rails)设置Rails应用程序,但我仍然无法克服错误Filetoimportnotfoundorunreadable:twitter/bootstrap.我在gem的官方Github上发现了这个问题,但是那里的解决方案都对我不起作用。这是我的设置:gem文件gem"twitter-bootstrap-rails"gem'font-awesome-rails'gem'sass-rails','~>3.2.3'group:assetsdo#gem'sass-rails','~>3.2.3'gem'

ruby-on-rails - rails 4 : How to upload files with AJAX

我想使用AJAX上传文件。在过去,我通过使用神奇的jQueryformplugin来实现这一点。效果很好。目前我正在构建一个Rails应用程序并尝试以“Rails方式”做事,所以我正在使用FormHelper和回形针gem来添加文件附件。railsdocs警告FormHelper不适用于AJAX文件上传:Unlikeotherformsmakinganasynchronousfileuploadformisnotassimpleasprovidingform_forwithremote:true.WithanAjaxformtheserializationisdonebyJavaScr

ruby-on-rails - rails 3.1 : Trouble on displaying images in mailer view files

我正在使用RubyonRails3.1,我想将我的网站Logo(即通过新Assets管道处理的图像)添加到电子邮件中。如果在我的邮件View文件中声明如下:它在production模式下不起作用(也就是说,我无法显示Logo图像),因为我认为Assets管道使用指纹识别技术并且在收到的电子邮件中它没有.检查电子邮件中的HTMLLogo元素,我得到如下信息:#withoutFingerprinting我该如何解决这个问题?在我的production.rb文件中,我有以下注释掉的代码:#Enableservingofimages,stylesheets,andjavascriptsfrom

Ruby 需要 'file' 和相对位置

所以我正在编写一些rspec测试,我为自己缺乏对Ruby的理解而感到尴尬。我的文件结构如下所示:GUI_Tests/Tests/test_spec.rbGUI_Tests/windows_gui.rbGUI_Tests/upload_tool.rb当我为test_spec.rb文件运行规范时,我需要像这样包含upload_tool文件:spec-r../upload_tool-fstest_spec.rb然后,upload_tool需要windows_gui.rb,如下所示:require'../windows_gui'我的问题是,为什么我必须相对于test_spec.rb(需要../

system.threading.Timer每天尝试同时制作计时器

我在控制台服务应用中使用system.threading.timer,并尝试每天同时制作计时器。最初,如果我在时间之前启动该应用程序,我会很好。就像我的时间是10:05,我从10:00启动该应用程序,我们很好。但是,如果我从10:06开始,我就不知道如何告诉时间台下24小时。谢谢你的帮助!publicvoidSetUpTimer(TimeSpanalertTime){DateTimecurrent=DateTime.Now;TimeSpantimeToGo=alertTime-current.TimeOfDay;if(timeToGo{EventLog.WriteEntry("MhyApp",

ruby - 试图构建一个 gem,得到一个 Gem::InvalidSpecificationException: "[...] are not files"

我正在尝试构建一个我编写的名为client_package的自定义gem,但它失败了。我的目录结构是这样的:client_packageGemfileGemfile.lockclient_package.gemspecRakefileReadme.md.gitignore.git...gitfiles...libclient_package.rbclient_packageversion.rbapi.rb...more...我的client_package.gemspec看起来像这样:#encoding:UTF-8requireFile.expand_path('../lib/clie