Passing parameters to the chart

6 views
Skip to first unread message

MarkHoffman

unread,
Dec 30, 2009, 6:42:23 PM12/30/09
to ZiYa Plugin
I'm both a ZiYa and a Rails newbie, so please forgive my ignorance,
but I'm having a tough time understanding how I am supposed to pass
parameters into my load_chart function.

Firstly, I'm using 2.1.5 of Ziya and Rails 2.3.5

Using the sample code, I have a blee controller with a callback called
load_chart. My initial routes.rb has this line:
map.load_chart '/blee/load_chart', :controller => 'blee', :action =>
'load_chart'

And my index.html.erb for blee looks like:
<%= ziya_chart load_chart_url, :width=>400, :height=>750 -%>

So what I've tried is modifying my routes.rb file to this:
map.load_chart '/blee/load_chart/:sort', :controller =>
'blee', :action => 'load_chart'

but that results in Rails complaining about an ambiguous route.

I tried modifying my index.html.erb to something like this:
<%= ziya_chart
load_chart_url, :width=>400, :height=>750, :sort=>'MySortParameter' -
%>

hoping that I could pull off the parameter inside load_chart by using
params[:sort], but that just showed nil.

I've tried various other combinations and permutations and nothing
seems to work. A search of the forum doesn't show much, which tells me
I'm doing this completely wrong.

Can anyone point me in the right direction?

fernand...@gmail.com

unread,
Dec 30, 2009, 6:47:24 PM12/30/09
to ZiYa Plugin
Hi Mark,

Cool ! You should be pretty close.

Just change the line to this

<%= ziya_chart load_chart_url
( 'my_sort_param'), :width=>400, :height=>750 -%>

You should now get params[:sort] in your controller.

-Fernand

MarkHoffman

unread,
Dec 30, 2009, 10:26:45 PM12/30/09
to ZiYa Plugin
Fernand - Thank you very much for your quick help! It seems so obvious
now, but I was pulling my hair out. This is working perfectly now!
Reply all
Reply to author
Forward
0 new messages