The Artima Developer Community
Sponsored Link

Ruby Buzz Forum
Rails for Strut-ters: Dealing with the view

0 replies on 1 page.

Welcome Guest
  Sign In

Go back to the topic listing  Back to Topic List Click to reply to this topic  Reply to this Topic Click to search messages in this forum  Search Forum Click for a threaded view of the topic  Threaded View   
Previous Topic   Next Topic
Flat View: This topic has 0 replies on 1 page
David Heinemeier Hansson

Posts: 484
Nickname: webster132
Registered: Jan, 2003

Rails is an open source web-application framework for Ruby
Rails for Strut-ters: Dealing with the view Posted: Feb 25, 2005 11:44 AM
Reply to this message Reply

This post originated from an RSS feed registered with Ruby Buzz by David Heinemeier Hansson.
Original Post: Rails for Strut-ters: Dealing with the view
Feed Title: Riding Rails
Feed URL: http://sedoparking.com/search/registrar.php?domain=®istrar=sedopark
Feed Description: The knowledge diff for all things Rails
Latest Ruby Buzz Posts
Latest Ruby Buzz Posts by David Heinemeier Hansson
Latest Posts From Riding Rails

Advertisement

Brian McCallister is doing an excellent job showing Strut-ters how Rails work by comparing it to their own environment. In this round, he’s taking a look at the oh-horror that is unleashing a real programming language on view logic. He finds that perhaps it’s not so bad at all comparing:

<% for invite in @invitations %>
...
<% end %>

...from Rails to the JSP approach of tag libraries with:

<%@ taglib uri="/tags/struts-logic" prefix="logic" %>
...
<logic:iterate name="invite" property="invitation">
...
</logic:iterate>

Indeed they do look similar. For more on that discussion, read my views on template languages and why the scriplet approach works in Rails.

As a sidenote, I’d like to suggest a few improvements to the tag/value mix that Brian has in his examples. For example, we could convert:

<form action="<%= url_for :action => 'register', :controller => 'rsvp' %>">
...
<input type="text"
name="invite_names[<%= slot %>]"
length="30"<%= "value='#{@invite.split_names[slot]}'" %>/>
...

To use a few more succinct FormTagHelper helper methods:

<%= form_tag :action => 'register', :controller => 'rsvp' %>
...
<%= text_field_tag "invite_names[#{slot}]", @invite.split_names[slot] %>

But that’s nitpicking. Brian is doing a fabulous job expressing the unknown in familiar terms. If you’re in need for something more visual on the Helpers, see this video demonstrating how to create a helper method in Rails.

Read: Rails for Strut-ters: Dealing with the view

Topic: Got Forte? Previous Topic   Next Topic Topic: `ruby -h`.unpack(%w[x558 155ax95 277 1a].join('aX')).join

Sponsored Links



Google
  Web Artima.com   

Copyright © 1996-2019 Artima, Inc. All Rights Reserved. - Privacy Policy - Terms of Use