bypass attr_accessible/protected in rails -
I have a model, when instantiates an object, then creates another object from the same user id.
Square Fu & gt; ActiveRecord :: Base after_create: create_bar Personal Def create_bar Bar.create (: user_id = & gt; user_id # and other attributes) In the end end
in Bar.rb to protect me from hackers Attr_protected.
class bar> ActiveRecord :: Base attr_protected: user_id, created_at ,: updated_at end
Now it stands as I appear to disable attr_protected or to create a new bar object without having bar object Can not User_id be empty ...
How do I accept bar objects: atti_protected without losing security from foo to user_id attribute? Try
:
def create bar = bar Build (... other parameters ...) bar.user_id = user_id bar.save! End
Comments
Post a Comment