2009/5/21 Stephan Wehner <[email protected]>

>
> Colin Law wrote:
> > Any thoughts anyone?
> >
> > Colin
> >
> > 2009/5/20 Colin Law <[email protected]>
>
> I guess here are two, but your question looks vague.
>
>
>
> Does
>
>  item.id == Item.named_scope_for_constant_record.id
>
> not become
>
>  "the item satisfies the condition of the
> named_scope_for_constant_record" ?
>
>
I am trying to avoid a db query each time I reference the (constant) id when
the application is running, that was the idea of looking it up when the
class is loaded and saving in a constant (which does not work in test mode
as the fixtures have not always been loaded when the class is loaded)


>
>
> If for the Item class there is just this one special record, can you
> force the id to be simply 0 by manipulating the database?
>

My initial solution was to have a well-known id for the special record.  The
problem with this in testing is that one has to then include the special
record with that id explicitly in the fixture. One cannot then make use of
the automatic fixup of habtm tables using the names of the fixture records
and so have to manually provide fixtures for the habtm join tables.  Plus
the idea of a record in the db having a well-known id is a bit yucky.

Colin


>
>
>
> Stephan
> --
> Posted via http://www.ruby-forum.com/.
>
> >
>

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "Ruby 
on Rails: Talk" 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/rubyonrails-talk?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to