# ActiveRecord in a generator?

**URL:** <https://www.ruby-forum.com/t/activerecord-in-a-generator/176193>\
**Category:** Rails\
**Created:** [September 26, 2009, 1:06am UTC](https://www.ruby-forum.com/t/activerecord-in-a-generator/176193 "2009-09-26T01:06:54Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![elliottg](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/e/b77776/32.png) [@elliottg](https://www.ruby-forum.com/u/elliottg)\
**Post date:** [September 26, 2009, 1:06am UTC](https://www.ruby-forum.com/t/activerecord-in-a-generator/176193/1 "2009-09-26T01:06:54Z")

</div>

How would one access ActiveRecord methods inside of  
Rails::Generator::NamedBase?

Thanks, Elliott

---

<div class="post-metadata">

**Author:** ![elliottg](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/e/b77776/32.png) [@elliottg](https://www.ruby-forum.com/u/elliottg)\
**Post date:** [September 26, 2009, 1:56am UTC](https://www.ruby-forum.com/t/activerecord-in-a-generator/176193/2 "2009-09-26T01:56:07Z")

</div>

On Fri, Sep 25, 2009 at 4:05 PM, elliottg [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:

> How would one access ActiveRecord methods inside of  
> Rails::Generator::NamedBase?

What kind of methods are you hoping to access? Or really, what are you  
trying to accomplish?

Colin

---

<div class="post-metadata">

**Author:** ![elliottg](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/e/b77776/32.png) [@elliottg](https://www.ruby-forum.com/u/elliottg)\
**Post date:** [September 26, 2009, 2:56am UTC](https://www.ruby-forum.com/t/activerecord-in-a-generator/176193/3 "2009-09-26T02:56:26Z")

</div>

Hey Colin,

In my generator I am creating some migrations, amongst other things,  
and then dropping into the shell to run rake db:migrate. After that, I  
want to seed the new table with a single record.

What’s the best way to do that from the generator?

Thanks, Elliott
