rubygems

How to override gem dependency?

雨燕双飞 提交于 2019-12-10 04:34:14
问题 I have 2 gems that depend on conflicting versions of hashie (one requires ~> 1.2.0 and the other requires 3.3.1): Bundler could not find compatible versions for gem "hashie": In Gemfile: restforce (>= 0) ruby depends on hashie (~> 1.2.0) ruby omniauth (>= 0) ruby depends on hashie (3.3.1) I'd like to keep both gems and use the higher version of hashie. Is there a way for me override one of the gem dependencies? 回答1: The standard advise is to use the higher version compatible . I do this way,

How to add “pry” when developing a Ruby gem

独自空忆成欢 提交于 2019-12-10 04:28:34
问题 I have a gem called "something". I would like to add pry as a development dependency when developing the gem. However I don't know how to load it. If I have "require something" inside lib/something.rb , when I release the gem, it throws a LoadError, because pry is only a development dependency. At the same time I don't want to keep adding and removing pry when I am committing code. What is the best way to require pry only when developing the application, but not require it as a dependency for

how to specify path for dependent gem in gemspec file?

北慕城南 提交于 2019-12-10 01:52:44
问题 I have created a gem(X) and it's not published. Now I am creating an another gem which will add the gem X as a dependency like this :- s.add_dependency "X" in gemspec file. since the gem(X) is not on rubygem or git or rubyforge, the bundle install command throws the error: could not find the gem X** I think specifying the path for X will do the trick, but how? 回答1: I think I see what @bor1s was pointing to in the SO post about git references. The gemspec file is about dependencies for

How does bundler work (in general)?

六眼飞鱼酱① 提交于 2019-12-10 00:51:19
问题 I'm pretty new to Ruby/Rails but I was taking a look at bundler and was wondering how it works exactly. Do you install a full set of gems like normal gem install XYZ and then use the Gemfile to pull a certain subset of those gems for use with a specific application? Or do you not install gems normally anymore and just include them in the Gemfile and then do a bundle install to include them all in a bundle that is then used with your application? Thank you so much for taking the time to answer

irb loading wrong ruby and gem path, using rbenv

别说谁变了你拦得住时间么 提交于 2019-12-09 23:31:54
问题 I started using rbenv for ruby version management and I'm finding that irb not loading the correct ruby version and gem version. Here are the details. irb Gem.path says: `>> Gem.path => ["/Users/Air/.gem/ruby/1.8", "/Library/Ruby/Gems/1.8", "/System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ruby/gems/1.8"]` Now in irb if I type: puts $: `>> puts $: /Library/Ruby/Site/1.8 /Library/Ruby/Site/1.8/powerpc-darwin11.0 /Library/Ruby/Site/1.8/universal-darwin11.0 /Library/Ruby/Site

Using pluginaweek's state_machine, can I reference the activerecord object during an event?

假如想象 提交于 2019-12-09 19:00:33
问题 I'm trying to implement a "suspend" event that transitions the object to the :suspended state. But I need to be able to "unsuspend", and return to the previous state. I added a previous_state field to the model, but I can't see how to access it inside an event block. This is the basic logic I'm trying to implement: event :suspend do owner.previous_state = self.state transition [:new, :old] => :suspended end event :unsuspend do transition :suspended => owner.previous_state.to_sym owner

How to install Rails 2.3.2 and 2.3.4 simultaneously on Ubuntu 9.04?

送分小仙女□ 提交于 2019-12-09 18:59:01
问题 I need to install Rails 2.3.2 and Rails 2.3.4 simultaneously on my Ubuntu 9.04 server. How do I do this? When I run: sudo gem install rails ...it installs version 2.3.4. Is there a single command I can use to also install 2.3.2 parallel to the default (latest) version? Thanks! 回答1: use the -v option to gem: sudo gem install rails -v=2.3.2 you'll have to do a separate install for 2.3.4 though 回答2: once installed you can specify which version you want to use for a specific rail app by editing

Getting Ruby on Rails environment working and installing sqlite3

时间秒杀一切 提交于 2019-12-09 18:48:02
问题 Trying to upgrade to the latest version of Ruby on Rails. I got ruby and rails installed ok (I think). C:\Users\benjaminw>ruby --version ruby 2.0.0p0 (2013-02-24) [x64-mingw32] C:\Users\benjaminw>rails -v Rails 3.2.13 I'm following an instructional guide out of a Ruby on Rails book but it's a little out of date. The next step says to download the sqlite3 db and extract the the files to the following folder C:/Ruby200/bin Then run the following command to make sure the db was installed

Heroku on Rails - Invalid DATABASE_URL

倖福魔咒の 提交于 2019-12-09 18:08:03
问题 EDIT: The general advice is to use CEDAR stack. Pretty new to RoR, Gems, Heroku and Git. Following tutorial: http://ruby.railstutorial.org/book/ruby-on-rails-tutorial Works smoothly on localhost, when deployed to Heroku got ConnectionNotEstablished error , that was solved here: https://stackoverflow.com/questions/7542745/heroku-error-activerecordconnectionnotestablished (BTW: following same tutorial) After changing production database to PostgreSQL (gem 'pg') it generates another error:

Is there a module like Perl's LWP for Ruby?

情到浓时终转凉″ 提交于 2019-12-09 17:17:57
问题 In Perl there is an LWP module: The libwww-perl collection is a set of Perl modules which provides a simple and consistent application programming interface (API) to the World-Wide Web. The main focus of the library is to provide classes and functions that allow you to write WWW clients. The library also contain modules that are of more general use and even classes that help you implement simple HTTP servers. Is there a similar module (gem) for Ruby? Update Here is an example of a function I