Using RubyMine 7, but this problem has happened since I started using RubyMine (back at RubyMine 3).
In short, I get dozens to hundreds of inspection warnings in my code because of missing fields/columns in my models. Thing is, the fields do exist and the code works fine. But RubyMine can't "see" the valid fields.
So two initial questions:
1) How does RubyMine know what fields a model has? Does it read the annotation headers or does it instantiate a model instance to reflect the know fields?
2) How do I let RubyMine know what fields my model has? Ideally in some automated way so I'm not manually maintaining a field list.
I did notice in RubyMine 7 a few things:
a) Some (not all) simple string fields in a model are found and the inspection doesn't complain about them.
b) Fields that are other data types including numeric/BigDecimal and integer are almost always flagged as unknown (that could be a red herring, but I really don't know)
c) Sometimes boolean fields are flagged as unknown as well, but sometimes they are not
d) RubyMine 7 has the plus os updating the warning to include the model it's looking at. Sometimes, it shows the correct model and sometimes it shows a parent model
As an example. This is an excerpt from a model, truncated for clarity:
# == Schema Information
# Table name: f_po_trans
# id :integer not null, primary key
# fiscal_year_id :integer not null
# po_group_id :integer not null
# po_num :string(255) not null
# po_num_raw :integer
# ... other fields
class Finance::PoTran < ::AuditedRecord
Inspection doesn't complain about the 'po_num' field (a string), but it does complain about the po_num_raw field?
We are using strong parameters, so while there are validates refs for some fields, there are no attr_accesible or other such methods in the models anymore.
It's driving me a bit crazy because I really want to see the green 'all-ok' indicator for my code, but right now, nothing I write will ever be problem free because of this.