When will Depot sample be updated to 2.1?
Wayde Gilliam
15 posts
|
Just curious. Thanks – wg |
Sam Ruby
197 posts
|
Thursday, June 05, 2008 |
Wayde Gilliam
15 posts
|
I see its been updated to work with 2.1 … but the code doesn’t seem so. For example on p.131 you have “respond_to { |format| format.js }” whereas in 2.1, I’d expect something more like this … respond_to do |format|
format.html { ... }
format.xml { ...}
format.js … |
Sam Ruby
197 posts
|
do…end and {...} accomplish the same thing (there is a minor difference as to precedence order, but that doesn’t apply here). The nested {...} blocks are optional, and aren’t needed in this case. The net is that the following are essentially identical:
respond_to { |format| format.js }
respond_to do |format|
format.js {}
end
Let me think about this a bit more. |
Wayde Gilliam
15 posts
|
You’re right. I still think it might be better to re-write the code for the Depot app using “do” statements for a number of reasons. First, 2.1 generated code uses this. Second, I think it makes for the most straight-forward way of falling back to plain HTML in non-AJAX-aware browsers and adding new formats. Anyways, like you said … they both accomplish the same thing. It just seems the “do” is more 2.1 and makes for more easily understand code when it comes to the cases mentioned above. Thanks |
Sam Ruby
197 posts
|
OK, I’m convinced. The next beta will use the following form: respond_to do |format| format.js end |
James West
70 posts
|
Hi I’m from a Delphi background and I must say that the second example feels much more natural and readable to me. Whatever I feel about the code examples provided I have to say that if this is the way that Ruby is going then this is the way I would like to be shown how to do things by this book. Just my tuppence worth. |
Wayde Gilliam
15 posts
|
Thanks Sam! Looking forward to the next drop. |
8 posts, 3 voices
