# Conflicting updates

**URL:** <https://www.ruby-forum.com/t/conflicting-updates/89396>\
**Category:** Radiant CMS\
**Created:** [March 20, 2007, 4:05am UTC](https://www.ruby-forum.com/t/conflicting-updates/89396 "2007-03-20T04:05:46Z")\
**Posts on this page:** 5\
**Page:** 2

<div class="post-metadata">

**Author:** ![dasch](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/d/b2d939/32.png) [@dasch](https://www.ruby-forum.com/u/dasch)\
**Post date:** [March 21, 2007, 7:54pm UTC](https://www.ruby-forum.com/t/conflicting-updates/89396/21 "2007-03-21T19:54:15Z")

</div>

Jim G. wrote:

> I’m testing things out for our eventual rollout of 0.6 and I’m  
> receiving this error when running rake db:migrate (or rake db:migrate  
> production)  
> "undefinded local variable of method ‘class\_name’ for #\<Page:  
> 0x27a850\>’
> 
> 0.5.2 was installed and working OK on mysql (pulled the source, not  
> from the gem)  
> But the MergeBehaviorsAndPages migration seems to fail every time.

The error exists because the migration calls save!, which attempts to  
validate, which uses the class\_name column which is created in  
migration 11 (app/models/page.rb:199). I don’t know an easy way to  
fix that. It works on an empty database because there are no pages  
to call save on. If I can get it to work, I’ll let the list know.

~~ Brian

---

<div class="post-metadata">

**Author:** ![dasch](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/d/b2d939/32.png) [@dasch](https://www.ruby-forum.com/u/dasch)\
**Post date:** [March 21, 2007, 5:10pm UTC](https://www.ruby-forum.com/t/conflicting-updates/89396/22 "2007-03-21T17:10:51Z")

</div>

Uh-oh. I’m really hoping there’s some better advice out there, but  
thanks Nancy.

I’m migrating from a fresh directory with only the appropriate config  
information changed. I’m not using any but the default behaviors, and  
all of my gems are up to date.

---

<div class="post-metadata">

**Author:** ![dasch](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/d/b2d939/32.png) [@dasch](https://www.ruby-forum.com/u/dasch)\
**Post date:** [March 21, 2007, 8:49pm UTC](https://www.ruby-forum.com/t/conflicting-updates/89396/23 "2007-03-21T20:49:31Z")

</div>

Brian,

I apologize for this problem. It comes up because of a recent change I  
made to mental. I’ll work with John to find a solution.

Sean

---

<div class="post-metadata">

**Author:** ![dasch](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/d/b2d939/32.png) [@dasch](https://www.ruby-forum.com/u/dasch)\
**Post date:** [March 21, 2007, 8:26pm UTC](https://www.ruby-forum.com/t/conflicting-updates/89396/24 "2007-03-21T20:26:28Z")

</div>

On Mar 21, 2007, at 2:53 PM, Brian G. wrote:

> The error exists because the migration calls save!, which attempts to  
> validate, which uses the class\_name column which is created in  
> migration 11 (app/models/page.rb:199). I don’t know an easy way to  
> fix that. It works on an empty database because there are no pages  
> to call save on. If I can get it to work, I’ll let the list know.

Horrible hack follows. But it works.

# Index: 010\_merge\_behaviors\_and\_pages.rb

— 010\_merge\_behaviors\_and\_pages.rb (revision 355)  
+++ 010\_merge\_behaviors\_and\_pages.rb (working copy)  
@@ -7,6 +7,7 @@

```
def self.up
  announce "converting behavior names to class names"

```

- add\_column :pages, :class\_name, :string  
Page.find(:all).each do |page|  
unless page.behavior\_id.blank?  
page.behavior\_id = page\_name(page.behavior\_id)  
@@ -14,6 +15,7 @@  
end  
end  
rename\_column :pages, :behavior\_id, :type
- remove\_column :pages, :class\_name  
end  
def self.down

---

<div class="post-metadata">

**Author:** ![dasch](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/d/b2d939/32.png) [@dasch](https://www.ruby-forum.com/u/dasch)\
**Post date:** [March 22, 2007, 2:13am UTC](https://www.ruby-forum.com/t/conflicting-updates/89396/25 "2007-03-22T02:13:09Z")

</div>

I normally fix migration validation problems by supplying a basic  
implementation within the migration itself - usually just

class Page \< ActiveRecord::Base  
end

with maybe an association or two. Using the actual models for migrations  
tends to lead to problems down the road.

* * *

From: removed\_email\_address@domain.invalid  
[[mailto:removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)] On Behalf Of Sean C.  
Sent: Thursday, 22 March 2007 6:48 AM  
To: removed\_email\_address@domain.invalid  
Subject: Re: [Radiant] migrating from 0.5.2 to 0.6rc2

Brian,

I apologize for this problem. It comes up because of a recent change I  
made to mental. I’ll work with John to find a solution.

Sean

[Previous page](https://www.ruby-forum.com/t/conflicting-updates/89396.md?page=1)
