odd number list for Hash error when using respond_to

Hello everyone,

Im using a charting plugin called openflashcharts and I seem to be
getting an error when trying to use respond to. Now I know hashes are
supposed to have an even amount of elements in them, but I dont see
where I am going wrong. Heres my code:
def index
       workouts = Workout.find_all_by_user_id(current_user.id)
    spinclasses = SpinClass.find_all_by_user_id(current_user.id)

     workouts_array = Array.new
     spinclasses_array = Array.new

     workouts.each do |w|
         workouts_array << [w.created_at.to_date, w.calories_burned]
     spinclasses.each do |sc|
         spinclasses_array << [sc.created_at.to_date,

   title = Title.new("Calories burned.")

    respond_to do |wants|
          @graph = open_flash_chart_object(600, 300, url_for(:action =>
'index', :format => :json))

        line = Line.new()
         line.text = "Line"
        line.width = 1
        line.colour = '#5E4725'
        line.dot_size = 5
          line.values = workouts_array

          chart = OpenFlashChart.new(title)
          render :text => chart, :layout => false


and heres my error:

odd number list for Hash
odd number list for Hash
syntax error, unexpected tIDENTIFIER, expecting '}'
         line.text = "Line"
syntax error, unexpected '}', expecting kEND
syntax error, unexpected $end, expecting kEND

Many thanks,



Could you try making your wants.html and wants.json blocks use
do...end instead of {...} and see if that works?

wants.html do
  @graph = ...

wants.json do
  line = Line.new()

Because of the linebreak ruby things you are calling wants.html with
no block or arguments and thinks that the block you have put on the
next line is a hash literal


Frederick Cheung wrote in post #947355: