views:

10

answers:

0

I'm trying to use the scriptaculous_slider plugin for rails. I don't understand the documentation.

Here's the example they give:

Example:
  <%= slider_stylesheet %>
  <%= slider_field :object, :method, :range => 1..10 %>

My use case is pretty simple. I have an object todo_item and I want to set a slider to change the value of the method portion_complete. But when I try something like

=slider_field todo_item, :portion_complete, :range => 1..10

I get an error `@#<AssignmentUser:0x105f5e5f0>' is not allowed as an instance variable name. Okay, that makes sense...here's the source code:

  def slider_field(object, method, options={})
    options.merge!({ 
      :change => "$('#{object}_#{method}').value = value",
      :hidden_fields => false
    })
    if slider_value = instance_variable_get("@#{object}").send(method)
      options.merge!({ :sliderValue  => slider_value })
    end
    hidden_field(object, method) <<        
    content_tag('div',content_tag('div', ''), 
      :class => 'slider', :id => "#{object}_#{method}_slider") << 
    slider_element("#{object}_#{method}_slider", options).html_safe
  end

and so clearly it's trying to convert the first argument into an instance variable, which it isn't. But, what to do? Am I supposed to put it in a form?

-# form_for todo_item do |f|
    = f.error_messages
    =# f.hidden_field :portion_complete
    = slider_field :todo_item, "portion_complete", :range => 1..10

Then I get another lovely error: undefined methodportion_complete' for nil:NilClass`. Obviously, I know I'm not doing it right, but I don't understand what I'm supposed to do, and I couldn't find any examples on google. I guess I feel frustrated that this passes as documentation.

If anyone has examples, or knows how I'm supposed to use this plugin, please let me know.

Thanks,