Forum: Ruby on Rails Question about validations

Announcement (2017-05-07): www.ruby-forum.com is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see rubyonrails.org/community and ruby-lang.org/en/community for other Rails- und Ruby-related community platforms.
A1247f73598357f06388e863c41aa624?d=identicon&s=25 Elias Orozco (elioncho)
on 2008-10-06 18:53
(Received via mailing list)
Hello,

Well I have implemented in my app a wall similar to the one found on
facebooks user profiles. I have created a wall_comments controller and
wall_comment model. Only friends can post in each others wall. On my
views I check that if the current user is not friend of a particular
user the form for posting a comments is not shown. On the
wall_comments controller I have a before_filter for the create action
that checks if the two users are friends. And on my wall_comment model
I have a validate_on_save method that checks again if the two users
are friends again.

Is this a good practice? That much validations? More queries, slower
response times? Any suggestions or is it ok like that?

Thanks,

Elioncho
23e4fc3add5443f51e55663cfc245d24?d=identicon&s=25 Erol Fornoles (Guest)
on 2008-10-06 19:56
(Received via mailing list)
On Oct 7, 12:50 am, elioncho <elion...@gmail.com> wrote:
> are friends again.
>
> Is this a good practice? That much validations? More queries, slower
> response times? Any suggestions or is it ok like that?
>
> Thanks,
>
> Elioncho

I'd drop the before_filter for the create action, since you're already
doing validations on the model side.
A1247f73598357f06388e863c41aa624?d=identicon&s=25 Elias Orozco (elioncho)
on 2008-10-06 22:42
(Received via mailing list)
I'll take your approach then. I'll make a validate_con_create method
on the wall_comment model. Thanks,

Elioncho
A1247f73598357f06388e863c41aa624?d=identicon&s=25 Elias Orozco (elioncho)
on 2008-10-06 23:06
(Received via mailing list)
I'll take your approach then. I'll make a validate_con_create method
on the wall_comment model. Thanks,

Elioncho
This topic is locked and can not be replied to.