# Changing Default Layout Generated By Scaffold

**URL:** <https://www.ruby-forum.com/t/changing-default-layout-generated-by-scaffold/191082>\
**Category:** Rails\
**Created:** [July 4, 2010, 9:30pm UTC](https://www.ruby-forum.com/t/changing-default-layout-generated-by-scaffold/191082 "2010-07-04T21:30:00Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![Adriano\_Dias\_da\_Sil](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/a/9f8e36/32.png) [@Adriano\_Dias\_da\_Sil](https://www.ruby-forum.com/u/Adriano_Dias_da_Sil)\
**Post date:** [July 4, 2010, 9:30pm UTC](https://www.ruby-forum.com/t/changing-default-layout-generated-by-scaffold/191082/1 "2010-07-04T21:30:00Z")

</div>

Good afternoon everyone.

Using the command:  
script/generate scaffold User name:string login:string password:string  
It created a layout in html standard for CRUD in app/views/users.

I wonder if you can change this layout (html) standard  
that is generated by scaffold, for example by placing the default  
layout of  
my system, so I do not need to change the layout of each CRUD  
individually.

Is it possible? If possible please suggest me a tutorial or me  
describe step-by-step how to proceed to effect that change.

Thank you.

Best Regards …  
Adriano Dias da Silva

---

<div class="post-metadata">

**Author:** ![Adriano\_Dias\_da\_Sil](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/a/9f8e36/32.png) [@Adriano\_Dias\_da\_Sil](https://www.ruby-forum.com/u/Adriano_Dias_da_Sil)\
**Post date:** [July 4, 2010, 11:23pm UTC](https://www.ruby-forum.com/t/changing-default-layout-generated-by-scaffold/191082/2 "2010-07-04T23:23:33Z")

</div>

If I understand your question, you can just delete the new layouts and  
the controller should default to the application layout.

On 7/4/10, Adriano Dias da Silva [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:

> individually.  
> You received this message because you are subscribed to the Google G.  
> “Ruby on Rails: Talk” group.  
> To post to this group, send email to removed\_email\_address@domain.invalid.  
> To unsubscribe from this group, send email to  
> removed\_email\_address@domain.invalid.  
> For more options, visit this group at  
> [http://groups.google.com/group/rubyonrails-talk?hl=en](http://groups.google.com/group/rubyonrails-talk?hl=en).

–  
Sent from my mobile device

---

<div class="post-metadata">

**Author:** ![Adriano\_Dias\_da\_Sil](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/a/9f8e36/32.png) [@Adriano\_Dias\_da\_Sil](https://www.ruby-forum.com/u/Adriano_Dias_da_Sil)\
**Post date:** [July 5, 2010, 2:05am UTC](https://www.ruby-forum.com/t/changing-default-layout-generated-by-scaffold/191082/3 "2010-07-05T02:05:40Z")

</div>

Good night.

Friend you have not understood the question …  
I want to change the layout before running the scaffold.

For example:  
I want to change the default layout of the scaffold.  
And when I run the scaffold is created the html (which I already  
changed)  
in app / views / users.

Got it??

Best Regards…  
Adriano Dias da Silva

* * *

---

<div class="post-metadata">

**Author:** ![Adriano\_Dias\_da\_Sil](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/a/9f8e36/32.png) [@Adriano\_Dias\_da\_Sil](https://www.ruby-forum.com/u/Adriano_Dias_da_Sil)\
**Post date:** [July 5, 2010, 5:10am UTC](https://www.ruby-forum.com/t/changing-default-layout-generated-by-scaffold/191082/4 "2010-07-05T05:10:03Z")

</div>

I see, so you want to design how the page will look before running the  
scaffold? If so, no there is no way to do this. Scaffolding  
autogenerates the html - so unless you modified some core rails class  
the output is always the same. I wanted to do the same thing when I  
started. Once you get used to erb you won’t really need to scaffold.

On 7/4/10, Adriano Dias da Silva [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:

> > > I wonder if you can change this layout (html) standard  
> > > Best Regards …  
> > > [http://groups.google.com/group/rubyonrails-talk?hl=en](http://groups.google.com/group/rubyonrails-talk?hl=en).  
> > > For more options, visit this group at  
> > > [http://groups.google.com/group/rubyonrails-talk?hl=en](http://groups.google.com/group/rubyonrails-talk?hl=en).

–  
Sent from my mobile device

---

<div class="post-metadata">

**Author:** ![Adriano\_Dias\_da\_Sil](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/a/9f8e36/32.png) [@Adriano\_Dias\_da\_Sil](https://www.ruby-forum.com/u/Adriano_Dias_da_Sil)\
**Post date:** [July 5, 2010, 11:27am UTC](https://www.ruby-forum.com/t/changing-default-layout-generated-by-scaffold/191082/5 "2010-07-05T11:27:32Z")

</div>

Also have a look at this :

[http://www.tonyspencer.com/2007/03/01/custom-scaffolding-for-rails/](http://www.tonyspencer.com/2007/03/01/custom-scaffolding-for-rails/)

---

<div class="post-metadata">

**Author:** ![Adriano\_Dias\_da\_Sil](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/a/9f8e36/32.png) [@Adriano\_Dias\_da\_Sil](https://www.ruby-forum.com/u/Adriano_Dias_da_Sil)\
**Post date:** [July 5, 2010, 10:38am UTC](https://www.ruby-forum.com/t/changing-default-layout-generated-by-scaffold/191082/6 "2010-07-05T10:38:25Z")

</div>

Adriano Dias da Silva wrote:

> Good afternoon everyone.
> 
> Using the command:  
> script/generate scaffold User name:string login:string password:string  
> It created a layout in html standard for CRUD in app/views/users.
> 
> I wonder if you can change this layout (html) standard  
> that is generated by scaffold, for example by placing the default  
> layout of  
> my system, so I do not need to change the layout of each CRUD  
> individually.
> 
> Is it possible? If possible please suggest me a tutorial or me  
> describe step-by-step how to proceed to effect that change.
> 
> Thank you.
> 
> Best Regards …  
> Adriano Dias da Silva

Greetings

I would recommend to take a look at this :

> **[\#58 How to Make a Generator - RailsCasts](http://railscasts.com/episodes/58-how-to-make-a-generator)**
>
> Short Ruby on Rails screencasts containing tips, tricks and tutorials. Great for both novice and experienced web developers.

you can create your custom generator exactly the way you like so you can  
use your own scaffold layout.

Also, in Ruby in Rails 3 :

> **[\#216 Generators in Rails 3 - RailsCasts](http://railscasts.com/episodes/216-generators-in-rails-3)**
>
> Short Ruby on Rails screencasts containing tips, tricks and tutorials. Great for both novice and experienced web developers.

At last but not least, have a look at this gem:  
[http://patshaughnessy.net/view\_mapper](http://patshaughnessy.net/view_mapper)
