简体   繁体   English

检索Rails中的field params字段

[英]Retrieving field params field in rails

I have been trying to analyze this problem very closely but I am still yet to find a good way to approach it. 我一直在尝试非常仔细地分析这个问题,但是我仍然没有找到解决这个问题的好方法。 (Hope my explanation is good enough) (希望我的解释足够好)

So I have three models [user, status and milestone] the status model belongs to the user model The milestone model belongs to status model and also to the user model through the status model 所以我有三个模型[用户,状态和里程碑]状态模型属于用户模型里程碑模型既属于状态模型,也属于状态模型的用户模型

Okay so I want to tie each milestone to a model by doing something like (milestone.build_status, this is pretty easy from the CLI, I have tested and tried it, and it works as expected.) 好的,所以我想通过做类似的事情将每个里程碑绑定到一个模型(milestone.build_status,这在CLI中非常容易,我已经测试并尝试了,并且可以按预期工作。)

So the big issue I am having is on the web page. 因此,我遇到的最大问题是网页上。 I am displaying all the statuses (I have already handled cases when the user enter a status) to user with a corresponding text field where they can enter their milestone, well when I do I post I can only get the params of the text field that was supplied (duh! isnt that obvious). 我正在使用相应的文本字段向用户显示所有状态(我已经处理了用户输入状态时的情况),他们可以在其中输入里程碑,当我发帖时,我只能得到以下文本字段的参数:被提供了(不是很明显)。

My question would be what are some possible approaches that I can use to figure which particular status that the user entered the milestone for. 我的问题是,有哪些可能的方法可以用来确定用户输入里程碑的特定状态。

I think you may be looking for Active Record Nested Attributes 我认为您可能正在寻找Active Record嵌套属性

This will allow your forms for your object of the User model to also accept input for its associated Status and/or Milestone objects for creating and updating each associated records all in one transaction. 这将使您的User模型对象的表单也可以接受其关联的Status和/或Milestone对象的输入,以便在一个事务中全部创建和更新每个关联的记录。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM