Forum: Ruby on Rails Form linking question

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.
C728d93eb5205cf20cac0c2928b0ad62?d=identicon&s=25 Jeff Jones (rurounijones)
on 2006-02-20 16:38
Hello all.

I currently have a method that is accessed from a form using this:

View:
<%= start_form_tag :action => :history %>
<p><label for="componentlog_cl_compname">Component Name</label><br />
<%= text_field 'componentlog', 'cl_compname', :class => 'mandatory',
:value => "#{session[:criteria]}" || nil %></p>
  <%= submit_tag "Search", :class => "button" %>
<%= end_form_tag %>

controller:
    unless request.post?
      render :action => 'search'
    else
      value = params[:componentlog][:cl_compname].strip
      etc etc etc
    end

Now this works fine and if possible I wouldn't want to change it. Now
lets say that I want to link to this form using a link_to with a POST
type to trigger the post event. Something along the lines of

<%= link_to "#{componentlog.cl_compname}", { :action => "history",
[componentlog][:cl_compname] => componentlog.cl_compname}, :post => true
%>

Trying the above results in a "Symbol as array index" error. How to I
construct the link_to statement so that it doesn't fall over.

It wouldn't suprise me if I found out I am doing everything in a less
than pefect way but hey, that is what first projects are for ;)

Many thanks.

Jeff
C728d93eb5205cf20cac0c2928b0ad62?d=identicon&s=25 Jeff Jones (rurounijones)
on 2006-02-20 17:04
> Trying the above results in a "Symbol as array index" error. How to I
> construct the link_to statement so that it doesn't fall over.
>
> It wouldn't suprise me if I found out I am doing everything in a less
> than pefect way but hey, that is what first projects are for ;)
>
> Many thanks.
>
> Jeff

It is at this point I learn about "_tags" from another post and shuffle
back into the shadows in a very embarrassed fashion

Jeff
This topic is locked and can not be replied to.