On Dec 25, 2005, at 6:49 PM, Sadys HumbleBee wrote:
Thanks, ryan. I’v joined the rails mailing list now, …
but I think as we going on, this problem is becoming more like a
I think if there is any compile tool in ruby that is powerful
enough to check the reference to my class and the database
structure to determine if the references are valid,
We are still talking about Rails, right? ActiveRecord determines the
columns in a database table dynamically at runtime. In other words,
Rails doesn’t check the ‘references’ to the table, it creates
them. Here an example SQL table definition and an associated
ActiveRecord sub-class definition.
create table friends (
id int not null auto_increment,
name varchar(100) not null
class Friend < ActiveRecord::Base
Now, by running the code
friend = Friend.new
friend.name = ‘Foo’
Rails automatically adds the following method the Friend class
@name = value
and then sends a message to that method with the ‘Foo’ argument.
This all happens because Friend is a sub-class of ActiveRecord (and
because you told your Rails app how to find the friend table via the
databases.yml file too).
or if there is any unit test automatation tool which can generate
cases for that purpose.
Unit testing is an important part of Rails apps, but I’d suggest
diving right into Rails development before you think about testing.
Code convertion is a way, but only suitable for experienced
programmer. And the defer of the attribute definition will cause
some word-complete function not work, such as that in source insight.
I’m not really sure what you meant by these statements.
And is it dangerous if I supply a library that any user can fill
any attributes into it by using method_missing? A library must be
able to deal with any misuage or malicious attack. Safety
guaranteed by documentation is not really safe.
ActiveRecord, like most classes, does in fact deal with sending
messages to non-existent methods: It throws an exception.
I’m not entirely sure what you’re driving at, but if you haven’t done
any Rails programming I’d suggest you start with a few tutorials
online. If you’re still intrigued by Rails and the Ruby language,
there are some great books over at http://
www.pragmaticprogrammers.com that I personally recommend.
~ ryan ~