Setting tags through fixtures with be_taggable.


Oshuma 01/12  
Rasputin-icon_thumb Anyone know of a way to set tags through a fixture file? For example, I have a Post model that's be_taggable, and I'd like to be able to set some default tags inside the RAILS_ROOT/test/fixtures/posts.yml fixture file. Know of a way to do this?
 
dorren 01/13  
Dorren_mii_thumb you should be able to setup fixtures using rails 2's named fixtures, which allow you to refer fixtures in other yml file by name. If you have tags.yml like this:
#tags.yml
agile_book:
  name: agile
  model_type: Book

rails_book:
  name: rails
  model_type: Book

ruby_book:
  name: ruby
  model_type: Book


then your books.yml can use named tag fixtures "agile_book", "rails_book", and "ruby_book"

# books.yml
agile_rails:
  name: agile dev with rails
  tags:
    - agile_book
    - rails_book

pickaxe:
  name: Programming ruby
  tags:
    - ruby_book

I haven't tested above code, hopefully it should work.


also this pdf shows some of new features in rails 2.
 
 
login or sign up to participate.




Money_dollar moneywill