There is so much written about the security threat of attr_accessible that I am beginning to wonder if I should even have any attributes in it. Here is the issue. I have a Message
model which has the following:
attr_accessible :body,:sender_id,:recipient_id
I do not have the update
or edit
action in my messages_controller
. With the new
and create
action I am able to create a new message and send it to a recipient. Only users who have logged in and meet certain conditions can message each other. I do that with the help of a before_filter
and the conditions work fine. The message is stored and can be viewed by the sender
and the recipient
. Perfect!
The question I have is that since :body,:sender_id,:recipient_id
are included in attr_accessible
, can a malicious user somehow change the :body,:sender_id,:recipient_id
of the original message? Should I just add these attributes to attr_readonly
as well so they cannot be modified once saved?
This question has been haunting me for practically all my models.