Redmine - Ruby - 寻找自定义字段的值 [英] Redmine - Ruby - Looking for the value of a custom field
问题描述
我检查了 IRC 的 redmine,但无法获得帮助.我在天气上很矛盾,无法将其粘贴到 Superuser、ServerFault 或此处,但由于我的问题是面向技术编程的,因此我决定在此处寻求帮助.
I checked IRC for redmine and was unable to get help. I was conflicted on weather to stick this on Superuser, ServerFault or here, but as my problem is technically programming oriented I decided to look for help here.
我们有一个 Mercurial 存储库系统,其布局基于满足我们需求的项目.我写了一些 shell 脚本,它们可以愉快地管理存储库并将它们放在正确的位置等.我试图调用这些脚本并从 Redmine 传递参数.我正在编辑 app/controllers/projects_controller.rb(第 75 -> 87 行)
We have a Mercurial repository system with a layout based on projects that addresses our needs. I wrote some shell scripts which work delightfully to manage the repository and put them in correct places etc. I am trying to call these scripts and pass them parameters from Redmine. I am editing the app/controllers/projects_controller.rb (lines 75 -> 87)
我已设法提取项目参数和当前用户,但我添加了两个自定义字段(使用 Redmine 管理中的自定义字段),并且我正在尝试访问这些自定义字段的值.有人知道我如何获得这些吗?
I have managed to pull the project parameters and current user, but I have two custom fields I added (using the custom fields in Redmine Administration) and I am trying to access the values of these custom fields. Does anyone have any idea how I can get these?
我当前的工作测试声明如下:
My current working test statement is below:
system "echo '#{@project.identifier}, #{User.current}' >> /tmp/rm.log"
推荐答案
使用 CustomField 模型.例如,
Use the CustomField model. For example,
# Find the first Custom Field
cf = CustomField.first
# Get the name
puts cf.name
# Find out if this Custom Field is for all projects
cf.is_for_all?
# If not, find out which projects are using it
cf.projects
为了解决这个问题,我刚刚安装了 Redmine-1.0.0,并在源代码和脚本/控制台中四处寻找.
To figure this out, I just installed Redmine-1.0.0 and poked around in the source and the script/console.
这篇关于Redmine - Ruby - 寻找自定义字段的值的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!