Named Fixtures plugin

Plugin details

This plugins can export/display fixtures with belongs_to/has_and_belongs_to_many relations using fixtures names instead of foreign key id.

Websitehttp://code.google.com/p/named-fixtures-exporter/ Repositoryhttp://named-fixtures-exporter.googlecode.com/svn/trunk/named_fixtures_exporter/ Author Fabien Jakimowicz Tags export LicenseMIT

Documentation

Install the plugin:
ruby script/plugin install http://named-fixtures-exporter.googlecode.com/svn/trunk/named_fixtures_exporter/

Examples
=============
With the following Message class:

class Message < ActiveRecord::Base
  belongs_to :sender
  belongs_to :recipient
  has_and_belongs_to_many :medias
end


You can dump your database content with a name for each belongs_to / has_and_belongs_to_many relations :

$> rake db:fixtures:display_named MODELS=Message
---
sent_message_751373555: 
  body: qu'en penses-tu ?
  sender: fabien
  type: SentMessage
  subject: de bien belles fraises
draft_message_893975074: 
  recipient: etienne
  sender: fabien
  type: DraftMessage
  subject: "RE : invitation jacuzzi" 
sent_message_751373556: 
  body: le meilleur jus d'oranges du monde!
  recipient: etienne
  sender: fabien
  type: SentMessage
  subject: tropicana 2
  medias: strawberry_sunset
received_message_507475146: 
  body: everything's ok
  recipient: fabien
  sender: etienne
  type: ReceivedMessage
  subject: test


If you already have fixtures, you can refresh them :

$> cat test/fixtures/users.yml
etienne:
  email: etienne@segonzac.info
fabien:
  email: fabien@jakimowicz.com

$> rake db:fixtures:display_named MODELS=User
--- 
fabien: 
  birthdate: 02/12/1981
  lastname: jakimowicz
  firstname: fabien
  contacts: etienne, user_987440063
  email: fabien@jakimowicz.com
user_987440063: 
  email: i_forget_it@demo.com
etienne: 
  email: etienne@segonzac.info
  lastname : segonzac
  firstname : etienne





Usage
2 rake tasks are availables :

rake db:fixtures:display_named # display fixtures for given MODELS
rake db:fixtures:export_named # export named fixtures from given MODELS


MODELS is a space separated string of model class names

Further Documentation

There is currently no advanced documentation for this plugin.

New documentation

Edit plugin | (0 older versions) | Last edited by: hardway, about 1 month ago