rubygems

What's the deal with rubygems on Debian? It's different and strange

橙三吉。 提交于 2019-12-09 16:14:02
问题 I've noticed at least the following oddities around rubygems on Debian (5.0 lenny in my case): Packages go into a different installation location: /var/lib/gems vs /usr/lib/ruby/gems The debian package is rubygems 1.3.6, and updating rubygems to the latest version (1.3.7) doesn't work: $ sudo gem update --system ERROR: While executing gem ... (RuntimeError) gem update --system is disabled on Debian. RubyGems can be updated using the official Debian repositories by aptitude or apt-get. Not all

updating rubygems to specific version on mac

两盒软妹~` 提交于 2019-12-09 15:59:13
问题 I need to update rubygems from 1.3.5 to 1.4.2 but apparently rubygems update just updates you to the latest version How can I update to 1.4.2? 回答1: You can install specific versions of RubyGems using RVM. rvm rubygems 1.4.2 回答2: After some research this worked for me: gem install -v 1.4.2 rubygems-update && ruby `gem env gemdir`/gems/rubygems-update-1.4.2/setup.rb If you need to use sudo to install gems then make sure to put a sudo in both calls: sudo gem install -v 1.4.2 rubygems-update &&

`add_frozen_gem_path': undefined method `source_index' for Gem:Module (NoMethodError) OR Gem.source_index is deprecated

限于喜欢 提交于 2019-12-09 13:38:23
问题 I am using rails 2.3.11, ruby-1.9.2-p320. Trying to run script/server but getting this error :- system@admin:~/apps/app_name/trunk$ script/server => Booting WEBrick => Rails 2.3.11 application starting on http://0.0.0.0:3000 /home/system/.rvm/gems/ruby-1.9.2-p320@gemset_name/gems/rails-2.3.11/lib/rails/gem_dependency.rb:21:in `add_frozen_gem_path': undefined method `source_index' for Gem:Module (NoMethodError) from /home/system/.rvm/gems/ruby-1.9.2-p320@gemset_name/gems/rails-2.3.11/lib

How can I remove Ruby on Rails 4 beta?

若如初见. 提交于 2019-12-09 10:18:17
问题 I'm new to Ruby and Rails and I installed the latest beta version of Rails 4 on my Mac, before I installed RVM to manage my versions. The Rails 4 beta is becoming a huge pain in the ass because it's the default version in every new tab I open in the terminal. How can I uninstall the Rails 4 beta and all references to it? 回答1: Except of uninstalling rails you need to uninstall railties gem - rails exec is only wrapper that will select most up-to-date railties gem. $ gem uninstall rails -v=4.0

3.days.ago, 2.hours.from_now etc without Rails?

北慕城南 提交于 2019-12-09 07:36:22
问题 Some book mentioned some gem to decorate numbers with #days , #megabytes , #minutes etc. Is this only in ActiveSupport, or is there a smaller gem that provides this functionality for use in (small) non-rails gems? I want to use this functionality as part of a DSL in a tiny little gem. 回答1: I'm not sure if there's another gem available besides ActiveSupport , but it would be really straight-forward to make a small version yourself: class Fixnum SECONDS_IN_DAY = 24 * 60 * 60 def days self *

Groups in a Gemfile in Rails 3?

ⅰ亾dé卋堺 提交于 2019-12-09 07:34:21
问题 In my Gemfile in Rails I have these groups: group :development, :test do gem "capybara" gem "database_cleaner" gem "spork" gem "launchy" end group :bdd do gem "cucumber-rails" gem "rspec-rails" end What does this mean? 回答1: From http://yehudakatz.com/2010/05/09/the-how-and-why-of-bundler-groups/: Specifying groups allows you to do two things. First, you can install the gems in your Gemfile, minus specific groups. For instance, Rails puts mysql and pg in a database group so that if you’re just

ruby strategy to convert floating point number with linguistics

爱⌒轻易说出口 提交于 2019-12-09 06:56:25
So I'm writing what I thought was a simple .rb file to convert a float number into a string. The string returns my floating point number in words. So if I have 11.11 then I would have eleven dollars and eleven cents So far I've extended the float class which has worked alright. I'm having trouble with how to convert the 11 cents into eleven cents. en.numwords would kick back eleven point one one. I've thought about trying out a hash to solve my problem where 11=>eleven cents. Any thoughts how I could implement this? Perhaps a better way to implement this? Here's what I have so far: require

Extending a ruby gem in Rails

独自空忆成欢 提交于 2019-12-09 06:32:15
问题 Let's say I have a Rails app that gets most of it's functionality from a gem (for instance, a CMS). If I now need to add some customisation (for instance, add a property to a user) what is the best practice way of doing this? If I customise the gem, then I will have issues with updating the gem in the future. What is the best approach to take here? 回答1: This question is quite old, but I feel it could use a bit more fleshing out. It is true that you can monkeypatch rails (and ruby) at run-time

acts_as_votable ordering by upvotes

梦想的初衷 提交于 2019-12-09 06:19:02
问题 I haven't been able to find anything that works so far for ordering questions by number of upvotes using the acts_as_votable gem. Here are my upvote and index methods: 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 and my questions view: <%= div_for(question) do %> <% if question.votes.size > 0 %> <div class="verifiedanswer"> <%=

Bundler: `bundle package` with a :git source

╄→гoц情女王★ 提交于 2019-12-09 05:23:14
问题 I'm trying to get my app to package my gems before deployment (to heroku) One of my gems in my Gemfile is a custom gem that I've written and I'm using the :git option of bundler to use the specific tag of my interest as such: gem "my_gem", :git => "git@github.com:my_username/my_gem.git", :tag => "v0.1.0" When I run bundle package however, this gem is not included into my vendor/cache directory. Is this a known issue, namely, that Bundler does not package gems that use the git source rather