Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

After installing paper_trail, get "irb: warn: can't alias context from irb_context." from rails console

I've tested this by running rails c both before and after git stash. On Rails 4.1 in Mavericks, after following the instructions to add the versions table and adding has_paper_trail to three models, whenever I run rails c I get

irb: warn: can't alias context from irb_context.

I've spent some time Googling without much luck, there's old threads talking about rspec, but I don't see how that's relevant since I'm not using it. Any ideas why this is happening?

like image 364
Waynn Lue Avatar asked Jun 10 '14 05:06

Waynn Lue


2 Answers

RSpec used to polute provide Object top-level methods, e.g. describe, context, etc. Fortunately they've got rid of all the monkey patching in version 3, and now all these methods are namespaced under RSpec.

One can change this behaviour through the expose_dsl_globally config flag. For backwards compatibility, it defaults to true.

The warning shows up when you open the console because paper_trail automatically loads its rspec helpers when rspec is found. And it calls RSpec.configure before you have the chance to tweak your own configuration.

One possible solution would be paper_trail to disable the automatically loading and let users to load it themselves when they see fit. However, I am not aware of the internals of the library, so I can't guarantee this wouldn't break other things.

Best!

like image 63
wicz Avatar answered Sep 17 '22 09:09

wicz


This is now fixed in papertrail 4.0.0, here's the commit.

like image 22
Waynn Lue Avatar answered Sep 20 '22 09:09

Waynn Lue