如何在Ruby中添加gem文件?

时间:2015-05-26 20:11:39

标签: ruby-on-rails ruby path coffeescript gem

我正在开始使用Rails,我正在尝试纠正"ExecJS::ProgramError in Pages#home"的问题,同时按照以下建议设置第一页

downgrading the gem coffee-script-source' from 1.9.1 to 1.8.0

但是我应该添加哪个gem文件?我看到GEM PATHS下的整个文件夹,如命令GEM ENV的结果所示

当我从命令行运行时,我得到以下错误(我认为这不是这样做的方式)

C:\Sites\myrails\App>gem coffee-script-source 1.8.0
ERROR:  While executing gem ... (Gem::CommandLineError)
    Unknown command coffee-script-source

真的很感激任何帮助吗?

My Rails env

RubyGems Environment:
  - RUBYGEMS VERSION: 2.4.7
  - RUBY VERSION: 2.1.5 (2014-11-13 patchlevel 273) [i386-mingw32]
  - INSTALLATION DIRECTORY: C:/RailsInstaller1.0/Ruby2.1.0/lib/ruby/gems/2.1.0
  - RUBY EXECUTABLE: C:/RailsInstaller1.0/Ruby2.1.0/bin/ruby.exe
  - EXECUTABLE DIRECTORY: C:/RailsInstaller1.0/Ruby2.1.0/bin
  - SPEC CACHE DIRECTORY: C:/Users/baskaran/.gem/specs
  - SYSTEM CONFIGURATION DIRECTORY: C:/ProgramData
  - RUBYGEMS PLATFORMS:
    - ruby
    - x86-mingw32
  - GEM PATHS:
     - C:/RailsInstaller1.0/Ruby2.1.0/lib/ruby/gems/2.1.0
     - C:/Users/baskaran/.gem/ruby/2.1.0
  - GEM CONFIGURATION:
     - :update_sources => true
     - :verbose => true
     - :backtrace => false
     - :bulk_threshold => 1000
  - REMOTE SOURCES:
     - https://rubygems.org/
  - SHELL PATH:
     - C:\RailsInstaller1.0\Git\cmd
     - C:\RailsInstaller1.0\Ruby2.1.0\bin
     - C:\RailsInstaller1.0\Ruby2.1.0\lib\ruby\gems\1.9.1\bin
     - C:\RailsInstaller1.0\DevKit\bin

根据建议 - 尝试执行以下操作

C:\Sites\myrails\App>gem install coffee-script-source -v 1.8.0
Successfully installed coffee-script-source-1.8.0
Parsing documentation for coffee-script-source-1.8.0
Installing ri documentation for coffee-script-source-1.8.0
Done installing documentation for coffee-script-source after 0 seconds
1 gem installed

但在尝试访问localhost:3000/pages/home

时仍然会收到以下信息
TypeError: Object doesn't support this property or method
  (in C:/RailsInstaller1.0/Ruby2.1.0/lib/ruby/gems/2.1.0/gems/turbolinks-2.5.3/lib/assets/javascripts/turbolinks.js.coffee)

2 个答案:

答案 0 :(得分:2)

通常这些事情都是通过Gemfile来管理的。如果你需要降级:

gem 'coffee-script-source', '1.8.0'

然后执行bundle install

请记住,您正在寻找的手动安装命令是:

gem install coffee-script-source -v 1.8.0

答案 1 :(得分:0)

我想通过编辑我的app目录中的set shell = WScript.CreateObject("WScript.Shell") set fso = CreateObject("Scripting.FileSystemObject") CurrentDirectory = fso.GetAbsolutePathName(".") sourcefile = fso.buildpath(CurrentDirectory, "manufacturer.bmp") MsgBox(sourcefile) 'Checks if the script is running elevated (UAC) function isElevated Set shell = CreateObject("WScript.Shell") Set whoami = shell.Exec("whoami /groups") Set whoamiOutput = whoami.StdOut strWhoamiOutput = whoamiOutput.ReadAll If InStr(1, strWhoamiOutput, "S-1-16-12288", vbTextCompare) Then isElevated = True Else isElevated = False End If end function 'Re-runs the process prompting for priv elevation on re-run sub uacPrompt 'Check if we need to run in C or W script interpreter = "wscript.exe" If Instr(1, WScript.FullName, "CScript", vbTextCompare) = 0 Then interpreter = "wscript.exe" else interpreter = "cscript.exe" end if 'Start a new instance with an elevation prompt first Set shellApp = CreateObject("Shell.Application") shellApp.ShellExecute interpreter, Chr(34) & WScript.ScriptFullName & _ Chr(34) & " uac", "", "runas", 1 'End the non-elevated instance WScript.Quit end sub 'Make sure we are running elevated, prompt if not if not isElevated Then uacPrompt destinationdir = fso.buildpath(shell.ExpandEnvironmentStrings("%windir%"), _ "system32") MsgBox(destinationdir) fso.CopyFile sourcefile, destinationdir 来添加

,我解决了这个问题
Gemfile

然后运行

gem 'coffee-script-source', '1.8.0'

由于