Make ActiveRecord objects not readonly
When you get readonly object, for instance
_project = Project.accessible_by_user(current_user).find(params[:project_id])
_project.readonly? # => true
And you want to edit it, you have to add :readonly => false to find as second parameter.
_project = Project.accessible_by_user(current_user).find(params[:project_id], :readonly => false)
_project.readonly? # => false
find method can be replaced by all, first, last etc.
Written by Bartłomiej Danek
Related protips
Have a fresh tip? Share with Coderwall community!
Post
Post a tip
Best
#Ruby
Authors
Sponsored by #native_company# — Learn More
#native_title#
#native_desc#