Rails API is not well defined


#1

Although somewhat new, I continue to struggle with passing the right
parameters to the Rails methods despite making direct reference to the
documentation. For example, I want to create a form:

form_tag :action => ‘deliver’, :id => @event.id, :class => ‘entry’

The class doesn’t show up. I’ve tried various combinations of hash
braces. Also, what if I want to pass in an id for the form tag itself
(e.g. #myentryform).

This is a little frustrating. Has anyone else experienced this? What
got you past this hurdle?

Mario


#2

On 5/22/07, Mario T. Lanza removed_email_address@domain.invalid wrote:

This is a little frustrating. Has anyone else experienced this? What
got you past this hurdle?

You have to establish when your first hash of parameters ends,
otherwise form_tag will assume your :action, :id, and :class options
are a single hash, when :class really needs to go in a separate hash.

This might help explain a bit more:

http://destiney.com/blog/rails-form-tag


Greg D.
http://destiney.com/


#3

Mario,

Consider this:

<%=start_form_tag({ :action=> ‘quick_create’, :upload_id => @upid },
{
:id => ‘quick_campaign_form’, :multipart => true})%>

You would put :class in the 2nd hash (eg. after :multipart). Otherwise,
:class goes into the url_for method and I think is used as a param in
the
form post/get.


#4

Hi,

I had the same problem for a long time. I would study the helper
methods, but just couldnt get my head around it all. It seemed so
vague. But the penny has just about dropped. I think understanding
the Agile Rails chapters on form and field tags has helped. But just
getting used to dealing with database results as models and feeling
comfortable with the terminology took time. Now it starts to seem
obvious. I guess the problem is that some of the Rails ‘Automagic’
can initially tend to be ‘Automysteryerious’ .

tonypm

On May 22, 10:29 pm, “Mario T. Lanza” <rails-mailing-l…@andreas-


#5

Thanks, guys. After a few attempts I eventually did get it working,
it’s just that often even with the help of the online RDoc it’s not
clear. I’m sure I’ll get better. :slight_smile:
Mario