# Scaffold\_all\_models and has\_and\_belongs\_to\_many

**URL:** <https://www.ruby-forum.com/t/scaffold-all-models-and-has-and-belongs-to-many/113795>\
**Category:** Rails\
**Created:** [September 5, 2007, 12:57am UTC](https://www.ruby-forum.com/t/scaffold-all-models-and-has-and-belongs-to-many/113795 "2007-09-05T00:57:11Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![esox\_ch](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/e/4da419/32.png) [@esox\_ch](https://www.ruby-forum.com/u/esox_ch)\
**Post date:** [September 5, 2007, 12:57am UTC](https://www.ruby-forum.com/t/scaffold-all-models-and-has-and-belongs-to-many/113795/1 "2007-09-05T00:57:11Z")

</div>

Hello,

I beg your pardon for this surely stupid problem, but I’m new in RoR  
world.

I created 3 views inheriting ActiveRecord::Base , lets call them a,b,c.  
a and b are linked by a table (a\_b\_fk) and the corresponding foreign  
keys.  
Now, when I generate the “administration” page by simply calling  
scaffold\_all\_models (from Scaffolding Extensions Plugin) everything  
works fine, but if I had has\_and\_belongs\_to\_many :a in b and  
symmetrically in a, I get an error :

compile error  
/var/www/rails/esoxCMS/vendor/plugins/scaffolding\_extensions/lib/scaffolding\_extensions.rb:1:  
syntax error, unexpected kDEF, expecting $end  
false def \_manage\_a

Could anyone explain me what’s I’m doing wrong?

Thanks in advance

---

<div class="post-metadata">

**Author:** ![esox\_ch](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/e/4da419/32.png) [@esox\_ch](https://www.ruby-forum.com/u/esox_ch)\
**Post date:** [September 5, 2007, 5:04am UTC](https://www.ruby-forum.com/t/scaffold-all-models-and-has-and-belongs-to-many/113795/2 "2007-09-05T05:04:13Z")

</div>

Sounds like a question for the Scaffolding Extensions Plugin  
author(s).

On Sep 4, 5:57 pm, Stefano G. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)

---

<div class="post-metadata">

**Author:** ![esox\_ch](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/e/4da419/32.png) [@esox\_ch](https://www.ruby-forum.com/u/esox_ch)\
**Post date:** [September 5, 2007, 7:46am UTC](https://www.ruby-forum.com/t/scaffold-all-models-and-has-and-belongs-to-many/113795/3 "2007-09-05T07:46:55Z")

</div>

Ok thanks, I’ll ask him. I thought I was doing something against “RoR  
logics”

---

<div class="post-metadata">

**Author:** ![esox\_ch](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/e/4da419/32.png) [@esox\_ch](https://www.ruby-forum.com/u/esox_ch)\
**Post date:** [September 5, 2007, 5:39pm UTC](https://www.ruby-forum.com/t/scaffold-all-models-and-has-and-belongs-to-many/113795/4 "2007-09-05T17:39:01Z")

</div>

Stefano G. wrote:

> Hello,
> 
> I beg your pardon for this surely stupid problem, but I’m new in RoR  
> world.
> 
> I created 3 views inheriting ActiveRecord::Base , lets call them a,b,c.  
> a and b are linked by a table (a\_b\_fk) and the corresponding foreign  
> keys.  
> Now, when I generate the “administration” page by simply calling  
> scaffold\_all\_models (from Scaffolding Extensions Plugin) everything  
> works fine, but if I had has\_and\_belongs\_to\_many :a in b and  
> symmetrically in a, I get an error :
> 
> compile error  
> /var/www/rails/esoxCMS/vendor/plugins/scaffolding\_extensions/lib/scaffolding\_extensions.rb:1:  
> syntax error, unexpected kDEF, expecting $end  
> false def \_manage\_a
> 
> Could anyone explain me what’s I’m doing wrong?
> 
> Thanks in advance

Most likely the reflection doesn’t exist or it isn’t  
:has\_and\_belongs\_to\_many. See line 1099 of scaffolding\_extensions.rb.  
If I had to guess, you are using:

class B  
has\_and\_belongs\_to\_many :a  
end

instead of:

class B  
has\_and\_belongs\_to\_many :as  
end

But I wouldn’t know for sure until you paste your model code.

Jeremy
