hi, all,

A blog application has posts and comments.

Each time a post is to be edited, a check needs to be made to
determine if the current user is the owner of the entry or not. Same
rule applies for deletion.

Similarly, each time a comment is to be deleted, a check needs to be
made to determine if the current user is an admin or not.

In other languages and frameworks( ie. catalyst or a custom made perl
framework) , a method is defined in the model class of the object and
in the controller, we load the object and call the method we defined
earlier to perform the check.

In this case, it would be (pseudocode like)

my $post = Posts->new();

if ( $post->check_access() )
{
    perform update/deletion
}
else
{
    output error message,  "Insufficient permission to perform desired
action"
}



My question is, how do we create methods in models and how to call
them from the controllers?
Any reference (url) would be much appreciated.

Thank you :)

--

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 this group at 
http://groups.google.com/group/rubyonrails-talk?hl=en.


Reply via email to