Rails 2.x and 3.x projects. How to?

I have a need to support both Rails 2.x and 3.x projects but when IDEA w/plugin sees Rails 3.x gems installed, it refuses to start 2.x rails with the message "Rails 2.x launcher         script was found instead of Rails 3.x one..."

Is there a way to configure IDEA to support both at the same time?

Thank you,
Shmel.

4 comments
Comment actions Permalink

If it is not a secret - why you need such a strange use case? =)

I don't beleive that it is widespread scenario, so I suggest to manually create simple ruby script run configuration for your 3.x (and probably 2.x) server. For this

1. Open RubyMine | Run | Edit Configurations
2. Press "+" button and create "Ruby" run configration
3. Fill name, specify rails server script ([your app]//script/rails - 3.x or [your app]/script/server - 2.x), specify script arguments, set your rails app home as working directory.
4. Go to "Logs" tab and specify rails server logs files if you need
5. Now you can use this configaration istead of predefined

0
Comment actions Permalink

Roman,

No, it is not a secret :)

I have two different applications  - one is Rails 3.0.x and another one Rails 2.3.x. In RubyMine they are configured as separate projects, however with the same Ruby SDK. Everything works as expected for Rails 3.x app. For Rails 2.x app though RubyMine refuses to start Rails server (configured under Rails section in Run | Edit Configurations) with error that launcher script is not 3.x. My guess RubyMine does it because it sees Rails 3.x gems installed, and ignores RAILS_GEM_VERSION='2.3.12' setting in environment.rb as well as gem 'rails', '2.3.12' in Gemfile.

Thank you for the workaround!

Shmel.

0
Comment actions Permalink

Shmel,

I have two different applications  - one is Rails 3.0.x and another one Rails 2.3.x. In RubyMine they are configured as separate projects, however with the same Ruby SDK

Ah, I thought you have one rails app which works on both rails versions

My guess RubyMine does it because it sees Rails 3.x gems installed, and ignores RAILS_GEM_VERSION='2.3.12' setting in environment.rb as well as gem 'rails', '2.3.12' in Gemfile


Looks like a bug, RubyMine gets rails version from Gemfile or environmnet.rb. Please open "Libraries" node in Project View, which rails gem is attached to your project there? Probably both 2.x and 3.x rails gems are attached.

0
Comment actions Permalink

Roman,

External Libraries section in Project view shows Rails 2.3.12 only, no 3.x listed there. However, your question helped to find the problem. I'm using IDEA with Ruby plugin and Rails app is just a part of larger project. It started with Rails 3.x module that later was removed and 2.x was added. Unfortunately, project .iml file had following leftovers that caused Ruby plugin to believe that it deals with 3.x:


  <component name="GemRequirementsHolder" version="3">
    <requirement>
      <requirement>
        <dependency name="rails" version="3.0.3" bound="EQUAL" git="false" path="false" doRequire="true" />
      </requirement>
      <source from="rails/src/Gemfile" />
    </requirement>
  </component>


After I cleaned it up, everything works as expected.


Thank you for help!
Shmel.
0

Please sign in to leave a comment.