![]() | Layouts in Rails 3.0 |
|
26 Aug 2010, 03:30
Bharat Ruparel (140 posts) |
Sam, I have an admin section in my rails 3 app. where I want to use a class AdminController < ApplicationController
Here are the contents of the layouts/admin.html.haml file: - content_for :secondary_nav do
= render :file => “layouts/application” Rails 3 is ignoring the admin layout all-together. Rails 2.3.8 doesn’t. Bharat |
|
27 Aug 2010, 00:27
Sam Ruby (465 posts) |
While that does sound like a bug, I am not aware of any bugs in that area. They layouts that I have tried continue to work. |
|
27 Aug 2010, 12:44
Bharat Ruparel (140 posts) |
It is a bug. I have gotten around it with ugly coding. So no worries. But I have opened up a ticket on lighthouse: https://rails.lighthouseapp.com/projects/8994/t… Other people have had similar experiences, see the thread: https://rails.lighthouseapp.com/projects/8994/t… The problem occurs when you are using nested layouts. I want to take this opportunity to share some of my thoughts with you. I have purchased a copy of this book for every release including this edition. The third edition was the best in the sense that it combined basic rails skills with deeper discussions of intermediate/advanced topics. That is what more experienced people like me pay for. We don’t mind you writing for the newcomers to Rails (we were there once ourselves :)). But try to mix some of the more advanced topics in your book along with the introductory materials. I am glad to see you delaying the final release a bit. We can help shape the more advanced materials by sharing our problems/experiences. Like this particular use/case. Layouts in Rails are very easy to implement, it is with more advanced topics like nested layouts that you go to yet another level all-together. Moreover, if things break from one release of rails to another, then it is this kind of knowledge that will help the readers of this book. I managed to get around this issue with some browsing through google reference and more specifically the tickets opened in Lighthouse. So in a nutshell, some materials in the book which is beyond introductory will be quite useful don’t you think? Regards, Bharat |
|
27 Aug 2010, 15:08
Sam Ruby (465 posts) |
Bharat: can I ask you to be more specific? Ideally as it relates to this particular instance? In the print edition of edition 3, the in depth coverage of layouts is on pages 545-552. In the beta 7 PDF edition of edition 4, the in depth coverage of layouts is on pages 363-370. Can you point to exactly what was present in edition 3 that is not present in edition 4 that would have made the identification of this bug (great job, BTW!) easier? |
|
27 Aug 2010, 17:36
Bharat Ruparel (140 posts) |
Hello Sam, As per the beta pdf 7.0, I downloaded it and read through it before posting my post above. The layouts coverage that you have is quite good really, but does not go far enough. What If you could address nested layouts where a controller does not use the default application.html.erb (haml) layout and uses its own layout to may be override it or supplement it then you will see the bug that I am talking about. My target posting my Rails 3.0 code on Github is coming Monday, I will post the URL here once I am done doing it. That way you can download my code and try it for yourself? Does that work for you? |
|
27 Aug 2010, 18:26
Sam Ruby (465 posts) |
Bharat: that’s a different topic. You found a bug in Rails 3.0, and are working with the Rails Core team to resolve it. That’s all goodness. I doubt I can add much value there. My role is in documenting Rails. I was responding to the following statement: The third edition was the best in the sense that it combined basic rails skills with deeper discussions of intermediate/advanced topics. Here I will disagree with you. The second edition was the best in that regard, but it only covered Rails 1.x. The third edition of the book is larger than the second edition, but less comprehensive. And neither directly covered the scenario you are now having trouble with. Meanwhile, the state of Rails documentation has dramatically improved, particularly when compared to the Rails 1.0 days. The Rails guides are pretty good. And if I see things that need to be fixed, I can talk to the people who are developing them, and they get fixed. But — in my opinion — I still don’t think that these guides are approachable by beginners. They are a great place to go if you know how to ask the right question. But until you know the right question to ask, they are not very helpful. Furthermore, there is enough differences between Rails 2 and Rails 3 that even people who thoroughly know Rails 2 will need a bit of re-education to once again know what the right questions are to ask. |
|
27 Aug 2010, 22:18
Bharat Ruparel (140 posts) |
Sam, So, what I am saying here is that Rails should not be documented in a vacuum. It has to reflect what works and what has changed. For example, if you see the threads that I mention above, you will see that there are no specific resolutions to the deviations from the standard documentation that is provided by Edge Guides or yourself. So I am merely suggesting that you try out nested layouts and you will see that it contradicts what you are writing in the book. There is always a chance that I am wrong and I would humbly accept it when and if I am proven wrong. Regarding my comment above “The third edition was the best in the sense that it combined basic rails skills with deeper discussions of intermediate/advanced topics.” It is entirely possible that it is a function of my learning curve too. I was intensely engaged in working on two Rails projects last year and may have found more use of the Third Edition since it was directly applicable to what I was doing then. So, that is a possibility. I thought that you wanted to keep the more experienced developers interested, so that is where I was coming from. The shopping cart example is very good for beginners and you should keep it there. Go a bit beyond what the Edge Guides are telling us in your in-depth coverage of Rails that is based on what currently works and what does not work and what are the work arounds. For example, the behavior of content_for and yield has changed in some subtle but important ways which I found by listening to Ryan Bates and googling around. That kind of information in a book format is invaluable.. That is what I was leading up to. As you yourself point out above “Furthermore, there is enough differences between Rails 2 and Rails 3 that even people who thoroughly know Rails 2 will need a bit of re-education to once again know what the right questions are to ask.” you are right on target and I have first hand experience of that fact in trying to upgrade my project to Rails 3. |
|
28 Aug 2010, 11:42
Sam Ruby (465 posts) |
I think we are getting closer in understanding what each of us is talking about. Agreed! the behavior of content_for and yield has changed in some subtle but important ways which I found by listening to Ryan Bates and googling around Thanks! Will investigate. Very helpful. Go a bit beyond what the Edge Guides are telling us While there will be instances where that is done, I’ll be upfront and will state that that there is no intent to do that in a systematic or comprehensive way. First, “beyond the edge” is too volatile. Heck, the rate of change of Rails already stretches the limit of what can be said about basic concepts in a book intended to be printed. More importantly, the focus of this book is on things that most people will need to know. Every section has been scrutinized from a “why do people need to know this?” perspective. In many cases, the fix was to simply add additional explanation as to why directly in the book itself. In some cases this involved pruning. Note: none of what I have just said is in any way intended to suggest that subtle but important changes to existing methods won’t be reflected. I do intend to investigate that, and incorporate what I find back into the back. Once again, thanks for the heads up! |
|
28 Aug 2010, 16:58
Bharat Ruparel (140 posts) |
Sam, |
|
30 Aug 2010, 00:53
Bharat Ruparel (140 posts) |
Hello Sam, http://github.com/bruparel/file_manager238 – with Ruby 1.8.7-p299 http://github.com/bruparel/file_manager3 – with Ruby 1.9.2-p0 Let me know if I am missing anything. Regards, Bharat |
| You must be logged in to comment |

