Freezing one gem in Rails 3

Hi,

I’m working on an app for a colleague.

He has written his own pagination class, but it is buggy and not
very DRY. Therefore I replaced it with the well-known “will_paginate”
gem, and that works just great.

The only problem is, that although this works on my machine, my
colleague (for whatever reason) refuses to install any additional gems
on his machine (I guess this is why he wrote his own paginator in the
first place).

My question: is it possible using rails 3.0.3, to unpack ONLY the
will_paginate gem to my vendor directory, so that it will work in the
project without my colleague having to install it?

I tried “bundle install vendor/gems”, but this installs everything to
this directory.

Grateful for any help.

So, no replies to my original question.

In that case I would be grateful if someone could tell me:
Is this a realistic thing to do?
Or, is it a silly idea which goes against some principle of Rails 3?

If so, is there any other way to wrap the functionality of a gem within
a specific Rails app for use in the above scenario?

Thanks

Hi Hassan,

Thanks for your reply.

What happens when you want to add a feature that requires adding
a different gem? Is he going to write his own version of that too? Or
when an existing gem needs an update?

Um, I’m afraid he might try …

Install everything, delete what you don’t want, and commit the one
gem you need. Done.

This is what I’m having trouble with. I’ve worked quite a lot with Rails
2.x, but this is the first thing I’ve done with Rails 3.x and am
therefore not very familiar with Bundler.

I did install everything and then deleted what I didn’t need, but then
when I tried to start WEBrick, it wouldn’t start complaining about
missing dependencies. I no longer remember the exact error message as I
rolled everything back after that, but I could reproduce it if that
helps.

What exactly do you mean by “Commit the gem you need”.
Am I missing a step?

Thanks very much for your help so far.

On Mon, Jul 25, 2011 at 9:27 AM, Jim B. [email protected]
wrote:

In that case I would be grateful if someone could tell me:
Is this a realistic thing to do?
Or, is it a silly idea which goes against some principle of Rails 3?

I can’t answer either of those directly, but – you previously said:

The only problem is, that although this works on my machine, my
colleague (for whatever reason) refuses to install any additional gems
on his machine (I guess this is why he wrote his own paginator in the
first place).

What happens when you want to add a feature that requires adding
a different gem? Is he going to write his own version of that too? Or
when an existing gem needs an update?

My question: is it possible using rails 3.0.3, to unpack ONLY the
will_paginate gem to my vendor directory, so that it will work in the
project without my colleague having to install it?

I tried “bundle install vendor/gems”, but this installs everything to
this directory.

  1. So install everything in vendor/gems and be done with it; how is
    that a problem? Or,

  2. Install everything, delete what you don’t want, and commit the one
    gem you need. Done. Or,

  3. Find a new, saner colleague to work with :slight_smile:

FWIW,

Hassan S. ------------------------ [email protected]

twitter: @hassan

Thank you for trying that out.
That’s exactly the error I got.
I’ll have a play with things over the next few days and if I figure out
a solution, I’ll post back here just to be complete.
But, I am surprised that this seems to be so hard to do …

Other than that, it seems my best bet is to try to get my colleague to
start installing gems :slight_smile:

On Mon, Jul 25, 2011 at 11:20 AM, Jim B. [email protected]
wrote:

I did install everything and then deleted what I didn’t need, but then
when I tried to start WEBrick, it wouldn’t start complaining about
missing dependencies.

Yeah, sorry, you’re right – I just tries that on a throwaway app and it
doesn’t seem to work. :slight_smile:

% rails s
Could not find rake-0.8.7 in any of the sources
Run `bundle install` to install missing gems.

Meh. So, either try to figure out why it’s now looking for everything in
vendor/gems – maybe everything listed under “DEPENDENCIES” in
your Gemfile.lock? – or just install everything and leave it there.

If you’re distributing the app to other users, that might be the safest
thing to do anyway.

Just a thought…

Hassan S. ------------------------ [email protected]

twitter: @hassan