Groups
Groups
Sign in
Groups
Groups
Ruby on Rails Taiwan
Conversations
About
Send feedback
Help
如何將一個model、table的id從零算起?在AR裡
9 views
Skip to first unread message
plaintext
unread,
Jul 13, 2008, 10:01:00 PM
7/13/08
Reply to author
Sign in to reply to author
Forward
Sign in to forward
Delete
You do not have permission to delete messages in this group
Copy link
Report message
Show original message
Either email addresses are anonymous for this group or you need the view member email addresses permission to view the original message
to Ruby on Rails Taiwan
在development的環境、透過active_record用sqlite3,
在測試時增增減減後,
即使把所有的內容都刪掉後,
甚至在sqlite3裡面將table刪掉再重建一個table,
而在 Model.create(:name => 'some')後,
id仍從以前的最後一筆繼續累積。
自己在想,mysql有truncate table,就可歸零,
sqlite雖沒有,但就用drop table、再create table;
在sqlite裡直接操作會歸零。
所以覺得好像是active record裡面好像是有累記model的id嗎?
從API的doc裡一時看不到怎麼將acrive record的id歸零,
所以不曉得要以什麼步驟可以歸零?
JellyCatz果凍喵
unread,
Jul 14, 2008, 12:52:51 PM
7/14/08
Reply to author
Sign in to reply to author
Forward
Sign in to forward
Delete
You do not have permission to delete messages in this group
Copy link
Report message
Show original message
Either email addresses are anonymous for this group or you need the view member email addresses permission to view the original message
to Ruby on Rails Taiwan
first~ id歸零沒有意義,那東西本來就會成長&只是值的代表,基本上其他欄位重要性與代表性會高過於id,就像留言板你比較會注意主題內容和誰
留的言,而非資料庫成長情形...else
then,id基本上由DB控管而非Rails,Rails對DB原生的東西管得很少,大都是資料連結&那個多出來的schema版本部份而已,so真
的要做應該要去找DB設定值之類的
Reply all
Reply to author
Forward
0 new messages