gem version dilemma with rails 3.1 - ruby-on-rails

I want to use ebayapi gem (https://github.com/codyfauser/ebay) with my rails 3.1 application.
If I add the gem in the Gemfile, rails doesn't run.
/Users/ssk/.rvm/gems/ree-1.8.7-2011.03/gems/money-1.7.1/lib/support/cattr_accessor.rb:7:in `cattr_reader': undefined method `id2name' for {:instance_writer=>true}:Hash (NoMethodError)
I removed the ebayapi gem and tried "require 'ebay'" but it said that "no such file to load".
Ebayapi gem works only with money 1.7.1 and I think that conflicts with rails 3.1 (maybe 3.0 as well).
Is there a way to workaround?
Thanks.
Sam

If it's truly incompatible, and you're up to fixing it yourself, then fork the projects in question on github, and update your Gemfile to point to your git repo (or even a local path to make editing a lot easier).
Here's an example:
gem 'money', :path => "~/dev/ruby/gems/money"
# or
gem 'money', :git => "git://github.com/my_account/money.git"
Once you've fixed it, send a pull request to the original project so they can include the fix.

Related

gems not showing in RubyMine

I added some gem I wrote in my local gem repo (some ~/.rvm/gems/ruby-2.0.0-p195/gems path), but when I require it in my RubyMine project, it is not found and indeed it does not appear in my RubyMine loaded gems, and I can't find how to add it. How can I circumvent this ?
There may be several things to try here - hard to tell what you have already done.
In RubyMine Tools > Bundler > Update
make sure you've got the gem in your Gemfile - either locally, or on a specific github repo...
gem 'mygemname', :path => '../myGem'
gem 'myGitGem', :git => 'git#github.com:MYREPOS/mygitgem.git'

Ruby On Rails, Where Do Bundler install gems that are fetched with :git=>'/your_name/project_name.git'?

This is my first question on StackOverflow. Please bear with me if I am doing it wrong.
I am working on a ruby on rails application and had to change the source code of a gem I am using in
/Users/username/.rvm/gems/ruby-2.0.0-p353/gems/gemname-4.1.0.
This works well and I make a fork of the gem on github, applied the changes I made, pushed, and change my gemfile line from
gem 'gemname'
to
gem 'gemname',:git=>"git#github.com:/name/gemname.git"
I run bundle install again and now the changes made are not applied to my application anymore.
When I do bundle show 'gemname' I saw the gem is install in
/Users/username/.rvm/gems/ruby-2.0.0-p353/bundler/gems/gemname-a0ed76fc98e2
I am not an expert on how bundle and github works. If anymore could explain how they work and what I should do to use my own forked version of the gem in my application, it would be very help!
Thanks in advance!
you could also write:
gem 'gemname', 'git://github.com/name/gem_name.git
or:
gem 'gemname', github: 'name/gem_name'
also be sure that you have your changes in master, and restarted your server after bundle
I ended up doing,
gem 'gemname',:git => "git#github.com:/myname/gemname.git", :branch => '1.1'
and it works fine now.
I think the problem is that I need to specify the branch 1.1 which is my branch, otherwise it uses the master's branch which my changes are not applied.

Local Gem assets not updating

I've forked a gem, and in trying to change it, decided to change the the gemfile from my git repository (which had been updating fine):
gem 'bootstrap-wysihtml5-rails', :git => 'git://github.com/Asherlc/bootstrap-wysihtml5-rails.git'
to the local directory (just the cloned git repository):
gem 'bootstrap-wysihtml5-rails', :path => '/Users/ashercohen/Documents/bootstrap-wysihtml5-rails'
Upon running either bundle update or bundle install, it shows the correct version number (updated since switching gem sources) in the readout. However, none of the files in the /vendor/assetspath seem to be getting updated in my Rails app. Is there some kind of caching thing I need to clear out?
I don't have a /vendor/cache file in my Rails app, and I'm confident that since the gem version is updating correctly in the bundler readout that the path is correct.
Is there some step I'm missing here?
Turns out Chrome was just aggressively caching the JS.

Custom gem - how to extract?

I am new to Ruby/Rails, and I have received a copy of a Rails project.
From what i have read online the gemfile contains the dependencies - i.e other libraries.
So if I have a "gem 'mycustomgem'" in the gemfile, and this gem is not available as open source, is there a way I can extract this gem from the project I have?
I have asked to write a new and alternative version of the rails project, where I am going to be needing this custom gem. Or do I have to contact the guy who wrote the custom gem?
Or have I completely missed something??
open you Gemfile and replace row
gem 'your_gem'
with
gem 'your_gem', :path => '/absolute_path_to_you_local_folder_with_gem'

Whats the best way to tweak ruby gems for code reading

To help understand the source code of various gems I often want to place various puts statements in the source code or even try using the ruby debugger.
But whats the best way of doing this?
Do you clone the project from github and make changes locally, if so how do you "force" the use of the local cloned code over the local gem on your machine. Do I just create some scripts that explicitly require the path of the cloned repos folder?
Or do should I use rvm to create a temp gemset, download the gem and modify it directly?
Are there any other methods ive overlooked? How would this change for gems designed for use within rails projects.
The way I usually do it when I want to make changes to a Gem:
Fork the repository on Github
Check it out and create a new branch for local changes
Use Bundler to manage dependencies for the project which uses the Gem
Change one line in the Gemfile to make it use the forked version of the Gem:
gem "thegem", :git => "git://github.com/name/thegem.git", :branch => 'mybranch'
or
gem "thegem", :git => "file:///path/to/thegem", :branch => 'mybranch'
with /path/to/thegem being the path to your local working copy.
The advantage is that you now already have a the perfect infrastructure set up for contributing your changes through a pull request :)
With Bundler.
In a Rails app simply edit the Gemfile and add:
gem "gem_name", :path => "~/MyGems/gem_name"
PS: Bundler work with any Ruby project.
You can use rvm to create a temp gemset, download the gem and modify it directly. A fast way to view/modify a gem is using gemedit :
Install:
gem install gemedit
Usage:
gem edit devise
or: gem edit devise -e mate

Resources