I am running into ActiveRecord::ConnectionNotEstablished error.
I have the following code
ActiveRecord::Base.establish_connection(:adapter => 'sqlite3', :database => 'users_vendors.db')
Class User < ActiveRecord::Base
has_and_belongs_to_many :vendors
end
class Vendor < ActiveRecord::Base
has_and_开发者_JAVA百科belongs_to_many :users
end
I am new to active records in ruby so any help would be appreciated
Is there any reason why you are connecting to the database in this fashion? The best way to do that is through a database.yml. http://wiki.rubyonrails.org/database-support/mysql#databaseyml_example
[Edit] For sqlite: http://wiki.rubyonrails.org/database-support/sqlite#databaseyml_example
精彩评论