views:

21

answers:

1

I dump the data from database to "test/fixtures/*.yml", but when I use rake db:fixtures:load, it complains the content of yml is invalid. Following is the content of my yml:

answer_00016: 
  id: 16
  content: |-
            <% output_once :define_aaa do %>
                Your stuff here
            <% end %>

Notice, the <% ... %> part is the content of the answer.

When I load the fixture, the error message is:

The exact error was:
  NoMethodError: undefined method `output_once' for main:Object

Following is my code to dump data:

data = ActiveRecord::Base.connection.select_all(sql % table_name)
file.write data.inject({}) {|hash, record|
     hash["#{table_name}_#{i.succ!}"] = record
     hash
}.to_yaml

Where is the problem? How can I fix it?

A: 

Fixed: http://stackoverflow.com/questions/2322413/how-do-i-escape-erb-code-in-fixtures

When I write to file, I should replace <% with <%% first

Freewind