I think you're doing it on the right way, patching the initialiser.

At Gemfile you have to use:

platform :ruby do
  gem 'mri-specific-gem'
end

plataform :jruby do
  gem 'jruby-specific-gem'
end

And if you need to something in a initialiser, you may check the platform 
using bundler stuff:

if Bundler.current_ruby.jruby?
  # jruby patch code
end

if Bundler.current_ruby.ruby?
  # ruby patch code
end

It's working great here ;)

PS: I'm not sure if it's ruby or mri, make sure before using it.

On Wednesday, May 14, 2014 11:24:55 AM UTC-3, Mohamed Wael Khobalatte wrote:
>
> Hey, 
>
> I found myself having to use jRuby in my app for a very very small but 
> essential piece of code. The code in question is bundled in a gem which I 
> require in Bundler under the jRuby platform, with all the rest of my gems 
> put under MRI. This was unfortunately necessary otherwise if I don't put 
> the rest under MRI Bundler will try to download jRuby versions of every 
> gem, which eventually breaks if a gem uses any C extensions.
>
> This has worked for me fine, but it required that I patch all my 
> initializers to make them load conditionally, i.e. depending on which 
> platform they are part of in Bundler. Because Rails treats them as regular 
> files with no mapping to their gems (Most of the files are gem initializers 
> in my case, but I concede that it might not the case for everyone), they 
> will load, and since some are not installed for one platform or the other, 
> this errors out. 
>
> Has anyone been subject to problems like this? There are many solutions 
> for my case, but I would like to know what people think about this or if 
> someone has solved this before in other way. 
>

-- 
You received this message because you are subscribed to the Google Groups "Ruby 
on Rails: Core" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to rubyonrails-core+unsubscr...@googlegroups.com.
To post to this group, send email to rubyonrails-core@googlegroups.com.
Visit this group at http://groups.google.com/group/rubyonrails-core.
For more options, visit https://groups.google.com/d/optout.

Reply via email to