Phlip wrote: > Derek Williams wrote: > > >> This is an issue with Sequel. >> > > Here we go again... > > Firstly, even this did not get around the 'missing id' issue: > > %w(progressive rock).each_with_index do |tag_name, x| > fixture_for Tag, :tag_name.to_sym do > self.id = x + 10 > self.name = tag_name > end > end > > fixture_for Post, :risen do > self.id = 1 > self.body = "Joan Crawford has risen" > self.title = "From the Grave" > self.author = "Blue Oyster Cult" > self.permalink = "http://botablog.cz" > self.tags << Tag.fixture(:progressive) > self.tags << Tag.fixture(:rock) > end > > Even giving everyone IDs only produced [nil, nil] in the tags. > > So the ultimate answer is to use fixtures for disconnected records, and > associate them with extra fixture code in the specs. > > Rereading your original post, and this one, I see a mistake. You have
:tag_name.to_sym but :tag_name is not a variable, it is a literal symbol, meaning both of the tags you have created are named :tag_name. You want to use tag_name, without the colon in front. The way you were doing is the same as having "tag_name".to_sym. Looking over the merb-fixtures sources I am not confident this will work how you want it to, but I could be missing something. Sequel is just too different from datamapper and there doesn't seem to be any code in merb-fixtures to really change it's behavior depending on your ORM. >> The method you are using would probably work fine if you were using >> datamapper instead. If you are still stuck, you could always try looking >> for a fixture framework designed to use sequel more appropriately. >> > > Until Merbists use fixtures more I doubt such work would SEO very high... > > This isn't a merb issue, it is a sequel issue. Merb does not have an ORM built in, there is no default, although datamapper is the closest to a default as it is part of the default stack. And I am sure many developers use fixtures with merb. I use fixtures using dm-sweatshop for datamapper. > And about datamapper, what if I did this? > > merb-gen model post_too --orm datamapper > > Now all I'd need to do is read post_too.rb to see how datamapper works, then > port that over to post.rb and toss post_too.rb. Right? > > Wrong! All that generated was a post_too_spec.rb, demanding I specify a > non-existent PostToo! > I don't think it is possible to mix ORMs like you are trying, you probably have to change the ORM in config/init.rb first. I'm not 100% on this one. This will cause more problems for you though, as the controllers and views (at the very least) will all have to be updated to use datamapper instead of sequel as well. As simple as this merb app is, it would probably be less work to start fresh. It looks like the main issue is you are attempting to learn merb through updating someone elses code, and more specifically, trying to write tests for code you do not understand. I would highly recommend starting a fresh merb app using datamapper unless you are really familiar with SQL and want to have more flexibility you can use sequel. I just had a quick look back at your previous posts, and you mention you use Rails as your day job, so I'd really recommend you use activerecord if you are having difficulties with datamapper or sequel, as it is something you are already familiar with, and you can use fixture frameworks that are designed for activerecord as well. Derek --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "merb" group. To post to this group, send email to [email protected] To unsubscribe from this group, send email to [email protected] For more options, visit this group at http://groups.google.com/group/merb?hl=en -~----------~----~----~----~------~----~------~--~---
