开发者

Rails - Data Migration vs. value in DB

I have a question about where values in dropdowns are coming from:

I have a migration that set up the original table with some initial values:

add_column :contracts, :signature_status_id, :integer

# lookup data
sig = SignatureStatus.new(:name => "Delivered")
sig.save!
sig = SignatureStatus.new(:name => "Signed")
sig.save!

I have a table called signature_statuses that contains the updated values:

id, name
1, 'Delivered; awa开发者_开发百科iting signature'
2, 'Delivered; awaiting full execution'
3, 'Terms being negotiated'
4, 'Fully executed and filed'

I have a form that contains the code to pull out the signature status:

<%= collection_select(:contract, :signature_status_id, @signature_statuses, :id, :name) %>

The collection select is pulling in "Signed" and "Delivered" when I want it to be from the DB. How do I make it do that.

Note: I think that the data was edited manually rather than a migration, but I'm not sure. I also searched the code for "signed" and "delivered", but the only place it shows up is in the migration.


I'm just wondering how are you getting that list of values in the signature_statuses table? Are you querying your development database? Is your application running in development mode? Is the database.yml file setup correctly to point to your development database?

Also can you post the controller code that populates the @signature_statuses variable.

A little more info and I'm sure people will be able to help.


Hmmm, this is a bit odd, but i suspect the following: there might be a method called name inside your signature_status model which is overriding the default one and which returns yes and no.


The key to debugging this is to look where

 @signature_statuses

is being set in the controller. If it's pulling from the database, then that is what is in the database. I wonder if there is more than one database involved, where your migration updated the development database, but you are running the query against production (or something like that).


It turns out I needed to run "rake db" and that fixed it.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜