Why doesn't RubyMine know about my Rails models' fields?

In a new, vanilla Rails project, RubyMine knows about a model's fields. In my project; Rails only  For example, in the Model Dependency Diagram I see associations (belongs_to, has_many, etc.), but no fields that correspond to database columns, either magic (e.g. id, created_at) or regular old data columns. I also see a warning everywhere the code refers to an accessor method that corresponds to a data column. What does it take for RubyMine to understand that a model has a field?

I'm using RubyMine 3.0.1, Rails 2.3.10, mysql 5.1, and the mysql2 gem 0.2.6 on a Mac. In general RubyMine seems to be running fine, and the app runs fine inside RubyMine. In particular, config/database.yml is there as it should be and the app and tests use it as expected.

A couple of possibilities:
- environment.rb has config.active_record.schema_format = :sql (since I use mysql schema features that the Ruby format doesn't support); does RubyMine care about that?
- the app doesn't have migrations going back to the beginning of time, and some migrations use execute "sql"; does RubyMine care about that?
Those are just wild guesses; I really have no idea what RubyMine needs.


RubyMine parses list of migrations or schema.rb file. As far as I understand you may generate schema.rb using one of standard rake tasks.


Well, Im not really sure what exactly RM parses (but it definitelly parses)) 'coz what otherwise excuses 700mb--1+GB of wasted RAM?) -- but on my WinXP it gives me hints in all those "belongs, has_many, validates.." etc
To experiment I just typed some of these giving them :non_existing_field as parameter -- RM complains
I pressed : and then control-space -- RM gives proper choices for fields -- see screenshot attached

UPD : no, it will not work in views. It just lists what is already mentioned in the view having no clue about any fields. I would suggest RM should include "guessed" stuff into code completion hint window. Like "if I have typed '@user.' and pressed control-space, RM should check if there is User model and make assumption that @user is instance of User and show all available stuff like fields, methods etc"


I did 'rake db:schema:dump' and restarted RubyMine and RubyMine seems generally aware of my models' fields now. Thanks!

I think it would be straightforward for RubyMine to do this for me, so I filed http://youtrack.jetbrains.net/issue/RUBY-7653.


Please sign in to leave a comment.