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]
     end
     spinclasses.each do |sc|
         spinclasses_array << [sc.created_at.to_date,
sc.calories_burned]
     end

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

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

        wants.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)
          chart.add_element(line)
          render :text => chart, :layout => false
        }
    end

  end

and heres my error:

/Users/Zack/Desktop/General/Rails/ergotech/app/controllers/charts_controller.rb:25:
odd number list for Hash
/Users/Zack/Desktop/General/Rails/ergotech/app/controllers/charts_controller.rb:30:
odd number list for Hash
/Users/Zack/Desktop/General/Rails/ergotech/app/controllers/charts_controller.rb:31:
syntax error, unexpected tIDENTIFIER, expecting '}'
         line.text = "Line"
             ^
/Users/Zack/Desktop/General/Rails/ergotech/app/controllers/charts_controller.rb:40:
syntax error, unexpected '}', expecting kEND
/Users/Zack/Desktop/General/Rails/ergotech/app/controllers/charts_controller.rb:54:
syntax error, unexpected $end, expecting kEND

Many thanks,

zack.

bump..

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 = ...
end

wants.json do
  line = Line.new()
  ...
end

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

Fred

Frederick Cheung wrote in post #947355: