Plugins - named fixtures exporter

StarAdd to favorites

Description


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


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


Installation



$> ./script/plugin install http://named-fixtures-exporter.googlecode.com/svn/trunk/named_fixtures_exporter

Fabien Jakimowicz

http://named-fixtures-exporter.googlecode.com

http://named-fixtures-exporter.googlecode.com/svn/trunk/named_fixtures_exporter

Rails' (MIT)

  • Currently 0.0/5 Stars.
  • 1
  • 2
  • 3
  • 4
  • 5

Model

Tags

Comments

Add a comment

Search Plugins

Query syntax

Plugins by Category

Sponsors

Rails Kits: Get Code. Get Moving.

Have a comment?