Jonathan Métillon wrote:
>I exported very easily to YAML using /admin/export
>And I created a new Radiant app with empty template, then:
>rake db:import TEMPLATE=export.yml
>The migration starts and fails at:
>
>== AddOptimisticLocking: migrated (0.4705s) =============
>
>rake aborted!
>You have a nil object when you didn't expect it!
>You might have expected an instance of Array.
>The error occurred while evaluating nil.delete
>
>You can review the full rake task log with trace here:
>http://paste.ubuntu-nl.org/23550/


The error you get should be related to the instruction

users_only = {'records' => {'Users' => data['records'].delete('Users')}}

Maybe in the yaml file you have created with the 'export' task there are 
no entries for the 'Users' key.

I too have used the import_export extensions with some problems.
I had to tweak the treatment of user data: e.g. in the yaml file I had 
to change the value for 'Created by' and 'Updated by'  to "1" (admin 
user) or nil otherwise the User object to be saved could not be 
instantiated correctly before saving the user record.

I had also to change the create_records method in radiant/setup.rb in 
order to maintain the original id's (otherwise associations between 
pages and page_parts would be lost):

def create_records(template)
        records = template['records']
        if records
          records.keys.each do |key|
            feedback "Creating #{key.to_s.underscore.humanize}" do
              model = model(key)
                          puts "Created model instance for " + key
              model.reset_column_information
                          record_pairs = order_by_id(records[key])

              step do
                record_pairs.each do |id, record|
                  newrec = model.new(record)
                                  #added by Luca to maintain the 
imported id
                                  newrec.id = id
                                  newrec.save
                end
              end
            end
          end
        end
      end


Hope this helps.

Luca Erzegovesi

-- 
Posted via http://www.ruby-forum.com/.
_______________________________________________
Radiant mailing list
Post:   [email protected]
Search: http://radiantcms.org/mailing-list/search/
Site:   http://lists.radiantcms.org/mailman/listinfo/radiant

Reply via email to