Vanilla 1.1.4 is a product of Lussumo. More Information: Documentation, Community Support.
Hello all again,
I was following this tutorial, www.aidanf.net/rails_user_authentication_tutorial and he utilizes a ruby native property of attr_accessor (which sets getters and setters). But what is interesting is how the model treats them as almost normal properties, setting them as it goes through mass-assignments and validation is aware of the properties. The only difference seems that the model doesn't save them to the database.
Is there a way to do this kind of functionality in akelos?
Akelos attributes can be set/get using these approaches (we don't have attr_accessor in PHP :( )
$User->get('password');
$User->set('password', 'mypass');
that will get/set a single attribute.
If you want to mass assign/retrieve attributes you can use
$attributes = $User->getAttributes();
$User->setAttributes($attributes);
If you need to do real work on setters/getters you can define in your config/config.php file
define('AK_ACTIVE_RECORD_ENABLE_AUTOMATIC_SETTERS_AND_GETTERS', true);
this is not enabled by default as it might cause recursion problems if you're not aware of it. When you add this setting calling
$User->get('password');
will look for a method like
$User->getPassword();
if it exists and will return the value provided by the specific getter. The same goes for setters
$User->set('password', 'mypass');
will look for a method like
$User->setPassword('mypass');
That is the way mass assignment getters and setters work in Akelos.
Hope you find it helpful.
1 to 3 of 3