Tag: rubygems

act_as_votable由upvotes排序

到目前为止,我还没有找到任何可以使用acts_as_votable gem通过upvotes订购问题的方法。 这是我的upvote和索引方法: def upvote @question = Question.find params[:id] @question.liked_by current_user redirect_to comment_questions_path end def index @comment = Comment.find params[:comment_id] @questions = @comment.questions end 我的问题观点: 0 %> 我应该在视图和控制器中放置什么才能使其工作?

如何在Rails 3应用程序中获取所有引擎的列表

根据Rails引擎扩展 Rails 2.x中的function ,可以做到 Rails::Initializer.new(Rails.configuration).plugin_loader.engines 此代码在Rails 3中不起作用 ActionController::RoutingError (undefined method `new’ for Rails::Initializer:Module): config/application.rb:12:in `require_or_load’ 在Rails 3中我需要做什么才能获得这样的引擎列表? 这是在主应用程序中扩展Rails 3引擎的控制器所需的

在Rails中扩展ruby gem

假设我有一个Rails应用程序,它可以从gem中获取大部分function(例如,CMS)。 如果我现在需要添加一些自定义(例如,向用户添加属性),这样做的最佳实践方法是什么? 如果我自定义gem,那么我将来会有更新gem的问题。 在这里采取的最佳方法是什么?

Rails pg gem不兼容的库版本

当我尝试在开发模式下访问我的Ruby on Rails网站时,我收到以下“不兼容的库版本”错误。 incompatible library version – /var/www/vhosts/launch.site.com/httpdocs/vendor/bundle/ruby/2.2.0/gems/pg-0.18.4/lib/pg_ext.so (LoadError) /var/www/vhosts/launch.site.com/httpdocs/vendor/bundle/ruby/2.2.0/gems/pg-0.18.4/lib/pg.rb:4:in `require’ /var/www/vhosts/launch.site.com/httpdocs/vendor/bundle/ruby/2.2.0/gems/pg-0.18.4/lib/pg.rb:4:in `’ /usr/local/rvm/gems/ruby-2.2.3/gems/bundler-1.10.6/lib/bundler/runtime.rb:76:in `require’ /usr/local/rvm/gems/ruby-2.2.3/gems/bundler-1.10.6/lib/bundler/runtime.rb:76:in `block (2 levels) in require’ /usr/local/rvm/gems/ruby-2.2.3/gems/bundler-1.10.6/lib/bundler/runtime.rb:72:in `each’ /usr/local/rvm/gems/ruby-2.2.3/gems/bundler-1.10.6/lib/bundler/runtime.rb:72:in `block in require’ /usr/local/rvm/gems/ruby-2.2.3/gems/bundler-1.10.6/lib/bundler/runtime.rb:61:in `each’ /usr/local/rvm/gems/ruby-2.2.3/gems/bundler-1.10.6/lib/bundler/runtime.rb:61:in `require’ /usr/local/rvm/gems/ruby-2.2.3/gems/bundler-1.10.6/lib/bundler.rb:134:in `require’ /var/www/vhosts/launch.site.com/httpdocs/config/application.rb:7:in `’ /var/www/vhosts/launch.site.com/httpdocs/config/environment.rb:2:in `require’ /var/www/vhosts/launch.site.com/httpdocs/config/environment.rb:2:in `’ config.ru:3:in `require’ config.ru:3:in `block in ‘ /var/www/vhosts/launch.site.com/httpdocs/vendor/bundle/ruby/2.2.0/gems/rack-1.6.4/lib/rack/builder.rb:55:in `instance_eval’ /var/www/vhosts/launch.site.com/httpdocs/vendor/bundle/ruby/2.2.0/gems/rack-1.6.4/lib/rack/builder.rb:55:in `initialize’ config.ru:1:in `new’ config.ru:1:in `’ /usr/share/passenger/helper-scripts/rack-preloader.rb:110:in `eval’ […]

如何使用“Elasticsearch”gem专门将elasticsearch与rails应用程序集成

我是新手,也是弹性搜索的新手。 我已经看到使用Tire,Searchkick和其他一些配置的其他资源,但我想使用Elasticsearch gem。 我有运行rails应用程序并在我的系统上运行Elasticsearch服务器,但我不知道如何配置它们以便彼此通信。 目前,我也面临着很多麻烦。 任何帮助将受到高度赞赏。

如何删除Ruby on Rails 4 beta?

我是Ruby和Rails的新手,在安装RVM来管理我的版本之前,我在Mac上安装了最新的Rails 4测试版。 Rails 4测试版正在成为一个巨大的痛苦,因为它是我在终端中打开的每个新标签中的默认版本。 如何卸载Rails 4 beta及其所有引用?

BlueCloth不支持Rails 3

BlueCloth与Rails 3兼容吗? 我不能让它工作,也许有人用它? 在要求’bluecloth’之后,应该在视图中提供一个名为’markdown’的帮助器,但这似乎不可用。

为什么gem`therubyracer`默认在Gemfile中注释掉了?

我创建了一个rails应用程序,并尝试启动rails服务器。 我收到了以下错误: /home/ritesh/.rvm/gems/ruby-1.9.3-p429/gems/execjs-2.0.1/lib/execjs/runtimes.rb:51:in `autodetect’: Could not find a JavaScript runtime. See https://github.com/sstephenson/execjs for a list of available runtimes. (ExecJS::RuntimeUnavailable) from /home/ritesh/.rvm/gems/ruby-1.9.3-p429/gems/execjs-2.0.1/lib/execjs.rb:5:in `’ from /home/ritesh/.rvm/gems/ruby-1.9.3-p429/gems/execjs-2.0.1/lib/execjs.rb:4:in `’ from /home/ritesh/.rvm/gems/ruby-1.9.3-p429/gems/uglifier-2.2.1/lib/uglifier.rb:3:in `require’ from /home/ritesh/.rvm/gems/ruby-1.9.3-p429/gems/uglifier-2.2.1/lib/uglifier.rb:3:in `’ from /home/ritesh/.rvm/gems/ruby-1.9.3-p429@global/gems/bundler-1.3.5/lib/bundler/runtime.rb:72:in `require’ from /home/ritesh/.rvm/gems/ruby-1.9.3-p429@global/gems/bundler-1.3.5/lib/bundler/runtime.rb:72:in `block (2 levels) in require’ from /home/ritesh/.rvm/gems/ruby-1.9.3-p429@global/gems/bundler-1.3.5/lib/bundler/runtime.rb:70:in `each’ from /home/ritesh/.rvm/gems/ruby-1.9.3-p429@global/gems/bundler-1.3.5/lib/bundler/runtime.rb:70:in `block in require’ from /home/ritesh/.rvm/gems/ruby-1.9.3-p429@global/gems/bundler-1.3.5/lib/bundler/runtime.rb:59:in `each’ from /home/ritesh/.rvm/gems/ruby-1.9.3-p429@global/gems/bundler-1.3.5/lib/bundler/runtime.rb:59:in `require’ […]

了解Gemfile.lock:是否可以删除Gemfile.lock然后再次运行bundle install?

我们会对此进行测试,但如果不应该发生这种情况,我们不想冒破坏我们的开发环境的风险。 是否可以删除Gemfile.lock? 我们在Rails 3.0.6上。

不小心运行$ gem update –system后无法运行rails服务器

我跑了gem update –system认为它会解决我遇到的问题,现在我无法运行rails server 。 它不会加载,而是我继续得到以下。 有人可以告诉我如何撤消这个并恢复到我运行更新之前? 我已经运行了git checkout ,但问题仍然存在…… /usr/local/rvm/gems/ruby-1.9.3-p194@global/gems/bundler-1.1.5/lib/bundler/rubygems_integration.rb:187:in `stub_source_index170′: uninitialized constant Gem::SourceIndex (NameError) from /usr/local/rvm/gems/ruby-1.9.3-p194@global/gems/bundler-1.1.5/lib/bundler/rubygems_integration.rb:353:in `stub_rubygems’ from /usr/local/rvm/gems/ruby-1.9.3-p194@global/gems/bundler-1.1.5/lib/bundler/rubygems_integration.rb:250:in `replace_entrypoints’ from /usr/local/rvm/gems/ruby-1.9.3-p194@global/gems/bundler-1.1.5/lib/bundler/runtime.rb:14:in `setup’ from /usr/local/rvm/gems/ruby-1.9.3-p194@global/gems/bundler-1.1.5/lib/bundler.rb:107:in `setup’ from /usr/local/rvm/gems/ruby-1.9.3-p194@global/gems/rubygems-bundler-1.0.7/lib/rubygems-bundler/noexec.rb:66:in `setup’ from /usr/local/rvm/gems/ruby-1.9.3-p194@global/gems/rubygems-bundler-1.0.7/lib/rubygems-bundler/noexec.rb:78:in `’ from /usr/local/rvm/rubies/ruby-1.9.3-p194/lib/ruby/site_ruby/1.9.1/rubygems/core_ext/kernel_require.rb:110:in `require’ from /usr/local/rvm/rubies/ruby-1.9.3-p194/lib/ruby/site_ruby/1.9.1/rubygems/core_ext/kernel_require.rb:110:in `rescue in require’ from /usr/local/rvm/rubies/ruby-1.9.3-p194/lib/ruby/site_ruby/1.9.1/rubygems/core_ext/kernel_require.rb:35:in `require’ from /usr/local/rvm/gems/ruby-1.9.3-p194/bin/ruby_noexec_wrapper:9:in `’