# ActiveRecord problems

**URL:** <https://www.ruby-forum.com/t/activerecord-problems/111420>\
**Category:** Ruby\
**Created:** [August 7, 2007, 4:38am UTC](https://www.ruby-forum.com/t/activerecord-problems/111420 "2007-08-07T04:38:55Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![yankees26](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/y/eb9ed0/32.png) [@yankees26](https://www.ruby-forum.com/u/yankees26)\
**Post date:** [August 7, 2007, 4:38am UTC](https://www.ruby-forum.com/t/activerecord-problems/111420/1 "2007-08-07T04:38:55Z")

</div>

This is the error I get:

/usr/lib/ruby/gems/1.8/gems/activerecord-1.15.3/lib/active\_record/base.rb:1857:in  
`method_missing': undefined method`body=’ for #Article:0x1374418  
(NoMethodError)  
from buzz.rb:60:in `add’  
from buzz.rb:98

It spawns from this function:

def add  
f = File.open Options.flags[:template]  
@article = Article.new  
@article.title = f.readline.gsub(/Title:/, ‘’).strip  
@article.author = f.readline.gsub(/Author:/, ‘’).strip  
@article.created\_at = Date.today.to\_s  
@article.body = BlueCloth.new(f.read).to\_html  
@article.save  
f.close  
rhtml = ERB.new(File.open(Options.flags[:erb]).read, 0, “\<\>”)  
html = rhtml.result self.get\_binding  
f2 = File.open Options.flags[:file], “w”  
f2.write html  
f2.close  
if Options.flags.index?  
self.index  
end  
if Options.flags.archive?  
self.archive  
end  
end

I’m not really sure why it only happens for body and not title, author,  
or created\_at. Maybe it has to do with body being of type ‘text’ in the  
mysql database (title and author are ‘varchar’ and created\_at is a  
‘date’).

If you need to see some more of the code, just give me the word. Any  
and all help is appreciated.

~ Jamie // yankees26

---

<div class="post-metadata">

**Author:** ![yankees26](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/y/eb9ed0/32.png) [@yankees26](https://www.ruby-forum.com/u/yankees26)\
**Post date:** [August 7, 2007, 4:54am UTC](https://www.ruby-forum.com/t/activerecord-problems/111420/2 "2007-08-07T04:54:51Z")

</div>

On 8/6/07, James R. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:

> def add  
> f2 = File.open Options.flags[:file], “w”  
> I’m not really sure why it only happens for body and not title, author,

Hi James,

What is the schema for articles in the DB to which you are connecting?  
Please provide the model file article.rb.

Ron

---

<div class="post-metadata">

**Author:** ![yankees26](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/y/eb9ed0/32.png) [@yankees26](https://www.ruby-forum.com/u/yankees26)\
**Post date:** [August 7, 2007, 4:56am UTC](https://www.ruby-forum.com/t/activerecord-problems/111420/3 "2007-08-07T04:56:51Z")

</div>

Hi James,

James R. wrote:

> This is the error I get:
> 
> /usr/lib/ruby/gems/1.8/gems/activerecord-1.15.3/lib/active\_record/base.rb:1857:in  
> `method_missing': undefined method`body=’ for #Article:0x1374418  
> (NoMethodError)  
> from buzz.rb:60:in `add’  
> from buzz.rb:98

Does Article.columns list body? What happens if you assign body a short  
“test” string?

Cheers,  
Mark

---

<div class="post-metadata">

**Author:** ![yankees26](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/y/eb9ed0/32.png) [@yankees26](https://www.ruby-forum.com/u/yankees26)\
**Post date:** [August 7, 2007, 4:59am UTC](https://www.ruby-forum.com/t/activerecord-problems/111420/4 "2007-08-07T04:59:40Z")

</div>

Wow…I feel dumb. I had left CocoaMySQL open and I guess I hadn’t  
clicked away from the column after putting body in and it never went  
into the schema. After exiting CocoaMySQL, it works.
