# Rails adding extra code?

**URL:** <https://www.ruby-forum.com/t/rails-adding-extra-code/93059>\
**Category:** Rails\
**Created:** [April 27, 2007, 1:23am UTC](https://www.ruby-forum.com/t/rails-adding-extra-code/93059 "2007-04-27T01:23:01Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![azazel](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/a/838e76/32.png) [@azazel](https://www.ruby-forum.com/u/azazel)\
**Post date:** [April 27, 2007, 1:23am UTC](https://www.ruby-forum.com/t/rails-adding-extra-code/93059/1 "2007-04-27T01:23:01Z")

</div>

My friend and I are working on a small app. Today he sent me some code.  
I plugged it into my setup but when I tried to retrieve it, I noticed  
CSS wasn’t working properly. Upon inspecting the code I noticed Rails  
had added a lot of html code.

I end up with: two css links (our own and scaffold.css), two   
tags, two tags, and two tags.

I really dont know why this happenned. I checked our scaffolds  
(generated by rails) and none have html code in the source. Like rails  
adds it by default when the page is requested. But I was under the  
impression that scaffolds are unnecessary and one could create its own  
pages.

How do I work that out?

Regards,  
az

---

<div class="post-metadata">

**Author:** ![azazel](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/a/838e76/32.png) [@azazel](https://www.ruby-forum.com/u/azazel)\
**Post date:** [April 27, 2007, 9:13am UTC](https://www.ruby-forum.com/t/rails-adding-extra-code/93059/2 "2007-04-27T09:13:17Z")

</div>

On 27 Apr 2007, at 01:23, Roberto R. wrote:

> My friend and I are working on a small app. Today he sent me some  
> code.  
> I plugged it into my setup but when I tried to retrieve it, I noticed  
> CSS wasn’t working properly. Upon inspecting the code I noticed Rails  
> had added a lot of html code.
> 
> I end up with: two css links (our own and scaffold.css), two   
> tags, two tags, and two tags.

IIRC, the scaffold creates a layout in the folder views/layouts.  
You’ll find \<%= yield %\> in the view code of the layout. Your .rhtml  
files are rendered in this layout if the controller says “layout  
‘scaffold’” (or whatever it’s called) on top. Both your views and the  
layout contain the and tags, that’s why cou see them  
twice. Layouts are very useful for extracting the common elements  
from your webpages.

> I really dont know why this happenned. I checked our scaffolds  
> (generated by rails) and none have html code in the source. Like rails  
> adds it by default when the page is requested. But I was under the  
> impression that scaffolds are unnecessary and one could create its own  
> pages.

Yep, scaffolds are just a quick way to generate a fully working CRUD  
sequence, but more complex websites will demand a more customized  
approach.

Best regards

Peter De Berdt
