This project is archived and is in readonly mode.

#4992 ✓committed
Jan Xie

new table name set by set_table_name not used by model

Reported by Jan Xie | June 28th, 2010 @ 09:11 AM

test case example:

class PostDraft < Post
  set_table_name 'post_drafts'
end

assert_difference("PostDraft.count") do
  Post.set_table_name 'posts'
  Post.create

  Post.set_table_name 'post_drafts'
  Post.create
end

Test will fail because the second Post.create will still insert into posts table instead of post_drafts table, but if you check Post.table_name you'll get 'post_drafts'. The correct behavior should be:

either A. insert into post_drafts table on the 2nd Post.create
or B. raise an error on the 2nd Post.set_table_name to keep consistence (if this is not a bug but a feature, lol)

(attached a patch for A)

Comments and changes to this ticket

Create your profile

Help contribute to this project by taking a few moments to create your personal profile. Create your profile »

<h2 style="font-size: 14px">Tickets have moved to Github</h2>

The new ticket tracker is available at <a href="https://github.com/rails/rails/issues">https://github.com/rails/rails/issues</a>

Tags

Pages