Topic: Does link_to_remote pass only strings?

Hi all,

I've just spent the best part of two hours debugging some particularly odd behaviour with link_to_remote, and thought I'd check with the group to see if my conclusion is correct: that all parameters passed to the underlying action by link_to_remote are passed as strings.

E.g. if I want to pass a start and end date, I can't just do what I'd normally do and pass a hash containing the objects:

<%= link_to_remote('<img src="/images/minus.gif" alt="Expanded" border="0" /> ' + name,
  :url=>{
    :controller => "report",
    :action => "toggle_category",
    :budget_period => { start_date => budget_period[:start_date], :end_date => budget_period[:end_date] },
  :update => "category_details#{category.id}") %>

Instead, I have to convert the times in question to their float values, and pass those:
<%= link_to_remote('<img src="/images/minus.gif" alt="Expanded" border="0" /> ' + name,
  :url=>{
    :controller => "report",
    :action => "toggle_category",
    :start_date => budget_period[:start_date].to_f,
    :end_date => budget_period[:end_date].to_f,
  :update => "category_details#{category.id}") %>

... and of course then in the toggle_category action, I do the following:
budget_period = { :start_date => Time.at(params[:start_date].to_f), :end_date => Time.at(params[:end_date].to_f) }

Is this right?  I mean, it works, but it doesn't appear particularly clean or intuitive.

TIA,
Duncan Bayne

Re: Does link_to_remote pass only strings?

yes, link_to_remote as well as link_to will only send strings. It's an http request, so everything is going to have to be strings.

ProgrammingBooks.org - Programming Books Ranked by Programmers
Turn of the Crank - My Personal Blog
Robot Walrus - My art prints & posters blog
My Game Ideas - Submit, rate, view video game Ideas

Re: Does link_to_remote pass only strings?

Ah, of course.  Thanks :-)