On Apr 13, 2010, at 10:43 PM, tispratik wrote:
Thanks for the quick reply Philip.
Unfortunately i am working on a windows machine and i am not aware of
any tool which shows the query being run.
In whatever windows uses as ".irbrc" put the following:
# Log to STDOUT if in Rails
if ENV.include?('RAILS_ENV') && !Object.const_defined?
('RAILS_DEFAULT_LOGGER')
require 'logger'
RAILS_DEFAULT_LOGGER = Logger.new(STDOUT)
end
Then run your queries in ./script/console and you should see the SQL.
An interesting workaround i found is by explicitly stating the
database.table_name in the intermediate model.
class ProjectRole < ActiveRecord::Base
set_table_name 'Y.project_roles'
end
Seems like when i do user.projects, rails assumes that the
project_roles table is in the latter model's database (which is true)
so it works.
But when i do, project.users, rails looks for project_roles table in
the database where users table is located (which is incorrect), so it
dosent.
But this dosent seem to be a good workaround as i have to hardcode the
database.table_name in the model class.
You're getting lucky again. Move one of the databases to another
server and the above will break.
Setup the logging so you can see the queries. That will make it clear
why one works and one doesn't.
-Regards,
Pratik
--
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 rubyonrails-
[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
.
--
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.