Tuesday, 9 April 2013

No identification of primary key on legacy database table

When using Rails against existing databases, it is unlikely that the Rails naming conventions for tables has been used. This means that models are likely to require the table name to be specified.

The old directive set_table_name has been removed from Rails. You now need to use:
self.table_name= :theTableName
However, this appears to have introduced a break, at least in Rails 4. Specifying the table name on a table that has id as the key column doesn't result in Rails identifying the key column, you still need to specify it:
self.primary_key= :id
 This means that whenever you set the table_name, you have to also set the primary key column name.

2 comments:

  1. Most boardrooms are by now well aware of the benefits of cloud computing and its important role in any company's formal IT portfolio. Yet many businesses remain sceptical about data security, with 87 per cent of financial services organisations admitting they do not plan to migrate their most important applications to the best data rooms due to security concerns.

    ReplyDelete
  2. Bush Telegraph is part of of} the free Slot collection at VideoSlots.com. Your multiplier increases every time one of many evildoers goes down, making a 260x line bet payout potential if all four are defeated. The Terminator Genisys Slot machine features 25 bet traces of motion and 카지노사이트 a formidable ninety five.76 per cent RTP. From the importance of the RTP of every recreation to the variations between bonuses and terms and conditions.

    ReplyDelete