Hi, Im writing a Plugin for redmine. My Problem is to map an ActiveRecord to an external database. Here's my class:
---------------------------------------------------------- class FtpUser < ActiveRecord::Base attr_accessor :created_at, :password; attr_writer :uid, :gid; attr_reader :user, :dir; establish_connection( :adapter => Setting.plugin_users['db_adapter'], :host => Setting.plugin_users['db_host'], :user => Setting.plugin_users['db_user'], :password => Setting.plugin_users['db_password'], :database => Setting.plugin_users['db_database'], :port => Setting.plugin_users['db_port'] ) self.table_name='users' self.primary_key='user' def initialize(params={}) if (params.include? :set_password && params[:set_password] == true) self.password=generateRandomPassword(10) end @user = 'c' + (self.id.to_int + 1000).to_s @dir="/var/ftp/#{user}" @created_at=DateTime.now @uid=2001; @gid=2001; end ... end ---------------------------------------------------------- When I call my class with the Controller like in this case: ---------------------------------------------------------- class UsersController < ApplicationController def index User.establish_connection #!!! @users=getActiveUsers end ..... private def getActiveUsers time=30.days.ago.beginning_of_day @users=User.where('created_at >= ?', time.to_datetime) end end ---------------------------------------------------------- the function 'where' is using the default database and not the database which is set in the 'establish_connection'-Function. How can I change this problem. Hope someone can help me. With best regards, spellsleeper. PS. 'user' is not really the classname :-). It's a place holder. -- 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 unsubscribe from this group and stop receiving emails from it, send an email to rubyonrails-talk+unsubscr...@googlegroups.com. To post to this group, send email to rubyonrails-talk@googlegroups.com. To view this discussion on the web visit https://groups.google.com/d/msgid/rubyonrails-talk/8a40a82a6b78d2b9d8badc8162470d9b%40ruby-forum.com. For more options, visit https://groups.google.com/d/optout.