So sorry for the big argue.

After digging the following
find --> find_every --> find_with_associations
--> select_all_rows  -->
construct_finder_sql_with_included_associations
--> column_aliases,

I suddenly found that in production environment,
Lexeme.column_names 's result and
Lexeme.columns.map{ |column| column.name } 's are having big
difference.

This is definitely wrong, and I realize this is definitely a bug in my
app, not in rails.

So, after re-examine, I found that I have changed Lexeme.column_names
in another models in validation process.
Everything goes well in development environment because in development
environment 'config.cache_classes' is set to false.
so every request will reload code, and Lexeme.column_names get the
right value every time.
But in production environment,  'config.cache_classes' is set to true,
my app coda get loaded only once,
so I did not notice that Lexeme.column_names has been changed in other
process.

Anyway, I had a better idea of find, include, joins and the whole find
action in finding this bug.
Fred, thanks for your advices.

On 3月10日, 午後11:23, boblu <[email protected]> wrote:
> I forgot to mention that these error only come out in production
> environment.
> Everything goes well in development environment.
>
> I don't understand why the action of find is different in production
> and development environment.
>
> I have read this 
> posthttp://www.spacevatican.org/2008/4/29/include-and-conditions,
> and I know there are old and new ways of eager loading in rails.
> And in my case, the old way is exactly what I want to do.
>
> the last example in this 
> posthttp://www.spacevatican.org/2008/6/22/the-difference-between-include-...,
> did the same thing I post here, and it seems everything went ok, just
> like mine in development environment.
>
> I'm wondering are there anyone try running the same find in production
> environment?
> And does it output the same error?
>
> On 3月10日, 午後6:22, boblu <[email protected]> wrote:
>
> > Fred, thanks for the quick reply.
> > I did ask the same problem 5 month ago.
> > I managed to use join instead of include like this
>
> > Lexeme.find(:all, :conditions=>'structures.id<10', :joins=>'left outer
> > join structures on structures.ref_id=lexemes.id and
> > structures.meta_id=0')
>
> > Since usually I need to specify conditions that have both lexemes
> > table and structures table's fields,
> > I used SQL instead of regular association in the above joins,
> > because the regular association joins does a inner join which will
> > give me nothing when I only want to find those lexemes without any
> > structures.
>
> > And now (5 month later), the reason I ask this question again are
> > 1. nobody gave me a reason why include goes wrong
> > 2. I really want a collection with eager loading instead of piles of
> > rows which joins gives.
>
> > Sorry for my foolness, but I don't quite understand what you said here
>
> > > the reason there's a difference
> > > when you don't have a  condition on the structures table is that in
> > > that case AR does the include in a completely different way.
>
> > Can you please explain this to me in details?
> > Thank you.
--~--~---------~--~----~------------~-------~--~----~
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