Project

General

Profile

Adding variable to the Safe array?

Added by Gary Mort about 14 years ago

Sorry about the simplistic question, but I'm new to ruby on rails.

I installed the acts_as_taggable_on plugin and setup a plugin to use it to add some variables to issues.

I was able to add the fields to the form and make issue taggable on multiple contexts, but the tag fields just would NOT save. Manually calling the tag save event with some data would work.

Finally, I have up on the plugin and edited the issue model and controller itself and had the same issue, until I added platform_list[I had used platforms as my tag constext, so platform_list is the SAFE_ATTRIBUTES constant:
SAFE_ATTRIBUTES = %w(
tracker_id
status_id
parent_issue_id
category_id
assigned_to_id
priority_id
fixed_version_id
subject
description
start_date
due_date
done_ratio
estimated_hours
custom_field_values
) unless const_defined?(:SAFE_ATTRIBUTES)

From what I can see here, what is happening is that redmine is removing all the issue fields sent in the put request which are not in this array. So my attempt and adding tags kept getting deleted on submit.

So my question is how would I modify this constant from within my own plugin? I don't want to redeclare it entirely, I just want to append to it my own variables so they don't get scrubbed.


Replies (4)

RE: Adding variable to the Safe array? - Added by Nick Peelman over 13 years ago

I’m looking for the same solution.

They have completely broken the ability to easily extend at least the issue model with this addition. I don’t know what other models they have given this treatment to...

RE: Adding variable to the Safe array? - Added by Eric Davis over 13 years ago

I agree, it's broken some of my code twice now. Could you file a bug report for it?

If you want to work around it, you can use a plugin hook and set the attribute directly: http://github.com/edavis10/redmine-budget-plugin/commit/43862fc3b907a5591eda2f624537d970a7e181ea

Eric Davis

RE: Adding variable to the Safe array? - Added by Nick Peelman over 13 years ago

Way ahead of you. #6000.

Eric Davis wrote:

I agree, it's broken some of my code twice now. Could you file a bug report for it?

If you want to work around it, you can use a plugin hook and set the attribute directly: http://github.com/edavis10/redmine-budget-plugin/commit/43862fc3b907a5591eda2f624537d970a7e181ea

Eric Davis

RE: Adding variable to the Safe array? - Added by Jean-Baptiste Barth over 13 years ago

Nick Peelman wrote:

Way ahead of you. #6000.

... with the same workaround, but I think we could all agree it's not the better way to go.

    (1-4/4)