On Sat, Jul 21, 2012 at 8:20 AM, Cortomix aa <[email protected]> wrote:

> I explain my problem. If I've got a  Person class in my model, with
> Rails I will have a class CreatePersons (for example) in db/migrate/
> with its attributes (name, address, telephone...)

Which is only used to create the database table, and which may be
overridden by later migrations. Once used, it's meaningless, other
than documenting the history of development.

> class Persona < ActiveRecord::Base
> end

> If I work with the Person class, I will have a class without attributes
> name or address!!

The class has those attributes; what makes you think it doesn't? It
just isn't necessary for them to be written in the file that defines the
class for them to exist; ActiveRecord derives them from the schema
of the database.

Open up a console session and play with it.
>> person = Person.new
>> person.name= "Bob"
>> person.name
=>  "Bob"

Create a non-AR class and experiment with it. Learning through
interactive exploring is one of the advantages of Ruby over Java :-)

-- 
Hassan Schroeder ------------------------ [email protected]
http://about.me/hassanschroeder
twitter: @hassan

-- 
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 https://groups.google.com/groups/opt_out.


Reply via email to