I'm looking for a part-time remote job.

Hire me

I'm the author of:

Mastering Redmine is a comprehensive guide with tips, tricks and best practices, and an easy-to-learn structure.

Check the book's project or

Buy the book

Social pages of the book:

By buying this book you also donate to Redmine (see this page).

Follow me:

Supporting ISSUE-id in your plugin

Redmine does not support issue IDs in other formats except the default one (which is just number). So to add such support I needed to patch many internal Redmine functions. And I needed to do this very carefully not to break the functionality of Redmine and of its third-party plugins.

This means, that, most likely, your plugin will suffer the installation of the ISSUE-id plugin. But this also means, that, probably, your plugin won’t be using new style of issue IDs.

So, let’s talk, what can you do to make your plugin compatible to ISSUE-id.

Displaying the right issue id

To display an issue ID Redmine just outputs issue.id, i.e., the same ID, which is used, e.g., to link associated records. Therefore, it’s impossible to alter this ID...

Usually, when I need to clone a view file and make it compatible to multiple Redmine versions, I prefer using functions, which work in all such versions (over, e.g., using if and else). Luckily such function exists for the issue ID as well!

Thus, to output an issue ID you should be using:

<%= issue.to_param %>

The to_param method outputs new-style issue IDs, if the plugin is installed (and used), and the old-style IDs otherwise.

The to_param method is used by Rails to generate IDs, which should be put into URLs. Thus, the Project model also uses this method to put the project identifier into URL instead of the numeric ID.

Using the special ID object

Sometimes an issue ID may be processed in some way and, as a result, you may have no access to the original issue object to be able to use the to_param method...

In such cases you may find the special IssueID object useful. This object returns a different ID representation depending on the context. Thus, id.to_s returns the ID in the new format and id.to_i returns the numeric ID.

The issue ID object is returned by the issue_id method, which gets added by the plugin:

id = issue.issue_id
new_id = id.to_s # ISSUE-NNN
old_if = id.to_i # NNN

Try using this method for your complex functions first. Then, if it fails, consider modifying them.

I tried replacing the id method with issue_id for the whole Redmine (yeah, I'm venturesome )... and it failed! But, still, most functionality worked fine.

Using the right issue id for URLs

For URLs you should be using the issue object, instead of just issue id:

url_for(:controller => 'issues', :action => 'show', :id => issue)

In this case Rails will use the to_param method, that has been mentioned above.

Terms of use | Privacy policy