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?

Freewind
  • 193,756
  • 157
  • 432
  • 708

1 Answers1

0

Fixed: How do I escape ERB code in fixtures?

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

Community
  • 1
  • 1
Freewind
  • 193,756
  • 157
  • 432
  • 708