Forums » Development »
Rails safe_attributes and plugin view hooks for user preferences can't set model data
Added by Anonymous about 5 years ago
I'm attempting to fix the Redmine reminder plugin which, I assume, was working before this commit https://www.redmine.org/projects/redmine/repository/revisions/15688/diff/.
I've debugged the plugin and found the source of the problem but I'm unable to find any documentation around the implementation done in this plugin, and a way to set additional safe_attributes extending from Redmine::Hook::ViewListener
. I have very limited Ruby & Rails experience, so please keep that in mind. The problem seems to be that the safe_attributes list in /app/models/user_preference.rb
doesn't allow the data from the plugin hook to be persisted to the database.
If I add the fields that are posted to the controller to the model, the data is saved correctly. How does one extended the safe_attributes list in this case?
I would also like to know the following:
1. Is the plugin implementation outdated now that safe_attributes was added to the UserPreference model and does the plugin actually need to be reworked?
2. Is Redmine perhaps lacking support for plugins to automatically extend the safe_attributes list in some way?
3. Wouldn't this plugin functionality make sense to be implemented into Redmine directly to further improve upon #13307 instead of a separate plugin?
Thanks
Replies (1)
RE: Rails safe_attributes and plugin view hooks for user preferences can't set model data - Added by Mischa The Evil about 5 years ago
Bruce Pieterse wrote:
1. Is the plugin implementation outdated now that safe_attributes was added to the UserPreference model and does the plugin actually need to be reworked?
I think so.
2. Is Redmine perhaps lacking support for plugins to automatically extend the safe_attributes list in some way?
No, it is supported. See #6000.
3. Wouldn't this plugin functionality make sense to be implemented into Redmine directly to further improve upon #13307 instead of a separate plugin?
Redmine core can't implement all functionality provided by all the plugins. That would cause Redmine to become bloatware.