プロジェクト

全般

プロフィール

Vote #67733

完了

Safe Attributes prevents plugin extension of Issue model...

Admin Redmine さんが約4年前に追加. 約4年前に更新.

ステータス:
Closed
優先度:
高め
担当者:
-
カテゴリ:
Issues_2
対象バージョン:
開始日:
2010/07/30
期日:
進捗率:

0%

予定工数:
category_id:
2
version_id:
20
issue_org_id:
6000
author_id:
16843
assigned_to_id:
0
comments:
3
status_id:
5
tracker_id:
1
plus1:
0
affected_version:
closed_on:
affected_version_id:
ステータス-->[Closed]

説明

I don’t know if this problem is limited purely to the issue model, or if it exists elsewhere in other models as well…

The addition of the safe_attributes method, well, really the entire paradigm of setting attributes this way, severely hamstrings other developers’ abilities to write plugins that extend the issue model. @accepts_nested_attributes_for@ goes out the window, because now all the submitted for elements for those get ignored and thrown into the bit bucket.

To some extent, I can understand why this was done, but I don’t understand doing it without providing a way to easily EXTEND the safe_attributes array, without having to set some constant to replace it completely. Hopefully this can be remedied soon, as I have plugins dependent upon extending the Issue model :\


journals

Same here, also had problems with issue model because of safe_attributes, and I'd like to have a clean way to extend it.

FYI, you may have a workaround using controller hooks : in my case, I noticed that safe_attributes= just prevents affecting the attributes, so I used @controller_issues_new_before_save@ and @controller_issues_edit_before_save@ to assign attributes manually (you can see it "here":http://github.com/jbbarth/redmine_datacenter/blob/master/lib/datacenter_issue_hook.rb, even if I'm not really proud of it ;))
--------------------------------------------------------------------------------
Jean-Baptiste Barth wrote:
> Same here, also had problems with issue model because of safe_attributes, and I'd like to have a clean way to extend it.
>
> FYI, you may have a workaround using controller hooks : in my case, I noticed that safe_attributes= just prevents affecting the attributes, so I used @controller_issues_new_before_save@ and @controller_issues_edit_before_save@ to assign attributes manually (you can see it "here":http://github.com/jbbarth/redmine_datacenter/blob/master/lib/datacenter_issue_hook.rb, even if I'm not really proud of it ;))

For now i'm just tweaking the codebase manually, at least until I hear a response on how they want to handle this project side (if they want to handle it at all or if this was all by design...). What you posted isn't *that* hackish, it would work pretty well. Its still just messier than it needs to be :(
--------------------------------------------------------------------------------
Fixed in r4491. You can now extend safe attributes for a given model using:

<pre>
Issue.safe_attributes 'foo', 'bar'
</pre>

or makes safe attributes conditional:

<pre>
Issue.safe_attributes 'foo', 'bar', :if => lambda {|issue, user| issue.author == user}
</pre>

You can have a look at @redmine/safe_attributes.rb@.
--------------------------------------------------------------------------------

Admin Redmine さんが約4年前に更新

  • カテゴリIssues_2 にセット
  • 対象バージョン1.1.0_20 にセット

他の形式にエクスポート: Atom PDF

いいね!0
いいね!0