Prev | Current Page 30 | Next

David Berube

"Practical Reporting with Ruby and Rails"

The remainder of the parameters
specify details of the connection: the server location, the name of the database,
access credentials, and so forth.
All of the models will use this connection by default, since you called establish_
connection on ActiveRecord::Base. However, you can also call establish_connection on
individual models that inherit from the Active Record base class, which lets you have
some models refer to one database and other models refer to a different database.
Next, you create a model:
class Player < ActiveRecord::Base
end
As you can see, it??™s not at all complicated to create a simple model in Active Record.
All of your record names are automatically read from your database, and you can access
them with simple getter and setter methods. The two lines used to create the Player class
are very powerful. They declare the new class as a subclass of ActiveRecord::Base. This
gives you access to a number of built-in methods and, through introspection and pluralization
rules, obtains the name of the underlying database table.


Pages:
18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42
Turcja 1 mimre.benton.pl Biuro księgowe Lublin Fundusze Emerytalne petrozawodzkich.waw.pl