Forum: Ruby on Rails Help with ruby=>html

Announcement (2017-05-07): www.ruby-forum.com is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see rubyonrails.org/community and ruby-lang.org/en/community for other Rails- und Ruby-related community platforms.
F639e0cdf2fa098b535d6ec766b2aee1?d=identicon&s=25 Szymon Nowak (g0nzo)
on 2006-02-26 22:35
Hi!

I'm new to ruby and rails and got problems with using basic methods like
form_tag or link_to etc to create what i need, i.e. to specify css class
or id or name of html elements.

I have problem with understanding rails api (it's just as an example):
form_tag(url_for_options = {}, options = {}, *parameters_for_url)

what parameters can i pass to form_tag? How to specify class, name or id
(those are things i need most)?

If someone could clarify the notation used here i'd be very grateful.
9ab183bb240ffd3a3966d5a615b4bdeb?d=identicon&s=25 Philip Ross (Guest)
on 2006-02-27 00:55
(Received via mailing list)
g0nzo wrote:
> I'm new to ruby and rails and got problems with using basic methods like
> form_tag or link_to etc to create what i need, i.e. to specify css class
> or id or name of html elements.
>
> I have problem with understanding rails api (it's just as an example):
> form_tag(url_for_options = {}, options = {}, *parameters_for_url)
>
> what parameters can i pass to form_tag? How to specify class, name or id
> (those are things i need most)?

Most of the tag helper methods (form_tag and link_to included) take an
options or html_options hash that is used for specifying tag attributes,
e.g:

<%= form_tag({:controller => 'my_controller', :action => 'my_action'},
       'class' => 'my_class', 'id' => 'my_id') %>

<%= link_to('link', {:action => 'my_action'},
       'class' => 'my_class', 'id' => 'my_id') %>

--
Philip Ross
http://tzinfo.rubyforge.org/ -- DST-aware timezone library for Ruby
This topic is locked and can not be replied to.