Re: 2 Newb Questions

Alex Wayne
Mon, 26 Feb 2007 02:08:44 -0000

Xavias wrote:
> Hey guys i''m new to rails and had 2 easy questions.
>
> First i''m using a simple ajax feature and need to use a hidden
variable
> for my values instead of the @ruby variables (example code below)
>
>     <%= form_remote_tag :url => {:action =>
''newlist'', :store => ''btc'',
> :today => ''02/25/2007''}, :update =>
''mainfrm'',
>   :complete => visual_effect(:bind_down, ''mainfrm''),
>   :before   => %(Element.show(''spinner'')),
>   :success  => %(Element.hide(''spinner'')) %>
>
> where i have :store => ''btc'', :today =>
''02/25/2007'' - i need to use a
> hidden field id but can''t find much on the correct syntax for
this. Can
> anyone help or point me to a good url?

You should be able to use the "hidden_field" form helper

  <%= form_remote_tag ... %>
    <%= hidden_field :post, :id %>


> Second i need to figure out how to loop and display only select fields
> from my table instead of All the fields.
>
> <% for entry in @entries %> <% for column in
Entry.content_columns
> %> <%=h entry.send(column.name) %>

This is old scaffold code, which is a bit hard to read.  You want
something like:

  <% for entry in @entries %>
Title: <%= entry.title %>
Author <%= entry.author %>
  <% end %>

Check out some of the beginner ruby on rails tutorials, or the book
Agile Web Development with rails.  Either will help you out a great
deal.