SitePoint Sponsor |
|
User Tag List
Results 1 to 6 of 6
-
Jun 16, 2009, 15:56 #1
- Join Date
- Nov 2008
- Posts
- 7
- Mentioned
- 0 Post(s)
- Tagged
- 0 Thread(s)
Simply Rails 2 - Chapter 6 - Page 171 - Layout
I just bought Simply Rails 2.0 by Patrick Lenz and I'm following along.
Everything is going fine until it's time to create a layout and style sheet.
On page 169, it says:
Layouts should be stored in the app/views/layouts folder. A layout template can basically be given any name, as long as the file ends in .html.erb. If the filename is application.html.erb, Rails will adopt this as the default layout.
On page 170, it says:
<%= stylesheet_link_tag 'style' %>
This code generates the HTML that includes an external style sheet in the page. By passing the string style, we ensure that the <link> tag that's generated will point to the URL /stylesheets/style.css.
When I reload the page /stories/new the page looks exactly the same as before (like page 164)
I took a look at the source code and the following stylesheet is referenced: "/stylesheets/scaffold.css?1245114256" . I deleted this stylesheet hoping this would make a difference. Didn't make a difference.
The layout template and style are not being recognized by the web server. I come to this conclusion because the "shovell" heading doesn't display.
My guess is the real problem is the layout template not being recognized. But I have no clue how to "fix" this problem.
-
Jun 16, 2009, 21:04 #2
- Join Date
- Jul 2005
- Location
- West Springfield, Massachusetts
- Posts
- 17,290
- Mentioned
- 198 Post(s)
- Tagged
- 3 Thread(s)
I'm guessing you're using a newer version of Ruby/Rails than when the book was written. I too experimented with scaffolding (back on pages 145-8), and then had to "undo" things, but I didn't have the same problem, so I'm guessing things changed since then.
Anyway, if you used
Code:$ ruby script/generate scaffold Story name:string link:string
Code:$ ruby script/destroy scaffold Story
Big Change Coming Soon - if you want your PMs save them now!
What you need to do to prepare for our migration to Discourse
A New SitePoint Forum Experience: Our Move to Discourse
-
Jun 17, 2009, 04:32 #3
- Join Date
- May 2008
- Posts
- 39
- Mentioned
- 0 Post(s)
- Tagged
- 0 Thread(s)
Do you have any other layouts in the layouts folder?
For example, if you have a stories controller, it will use stories.html.erb layout instead of application.html.erb if it exists.
-
Jun 17, 2009, 16:34 #4
- Join Date
- Nov 2008
- Posts
- 7
- Mentioned
- 0 Post(s)
- Tagged
- 0 Thread(s)
Thank you Mittineague and Delameko!
Scaffolding was definitely the problem. I put the following command in to destroy the scaffolding:
$ ruby script/destroy scaffold Story name:string link:string
And Delameko, about your comment:Do you have any other layouts in the layouts folder?
For example, if you have a stories controller, it will use stories.html.erb layout instead of application.html.erb if it exists.
-
Jun 17, 2009, 18:38 #5
- Join Date
- Jul 2005
- Location
- West Springfield, Massachusetts
- Posts
- 17,290
- Mentioned
- 198 Post(s)
- Tagged
- 3 Thread(s)
It may be true that the book says
Originally Posted by jonlyles
Layouts should be stored in the app/views/layouts folder. A layout template can basically be given any name, as long as the file ends in .html.erb. If the filename is application.html.erb, Rails will adopt this as the default layout.Big Change Coming Soon - if you want your PMs save them now!
What you need to do to prepare for our migration to Discourse
A New SitePoint Forum Experience: Our Move to Discourse
-
Jul 26, 2009, 17:00 #6
- Join Date
- Oct 2006
- Posts
- 4
- Mentioned
- 0 Post(s)
- Tagged
- 0 Thread(s)
Scaffolding was the problem for me too.
I was racking my brain recreating all the files, looking for typos. Thanks for the info.
Bookmarks