Rails:分析页面上的用户更改以插入数据库
我似乎无法提出简洁的问题,但无论如何:
我目前尝试编写一个应用程序,允许用户自定义保存他们的状态。但是,我不知道如何将自定义信息传递给控制器操作。
我不需要使用 link_to :controller => "controller, :action => "create", :params # => paramters
我可以轻松地将状态作为 JSON 对象传递,但是我如何传递自定义?
a) 我让用户在其中选择两个人许多人可能喜欢以这种方式显示:A、B 和其他 6 个人都喜欢这样,所以我必须能够更新类似的数组
b) 我希望允许用户删除评论,因此我。必须传递剩余评论的数组
有人有建议吗?
I dont seem to be able to formulate concise question, but anyways:
I currently try to write an app which allows users to customizable save their statusses. However, I dont know how to pass the customized information to the controller action.
Dont I have to use link_to :controller => "controller, :action => "create", :params # => paramters
I can easily pass the status as a JSON object, but how do i pass the customizations?
a) i let the users choose the two persons among the many people that may like to be shown in the manner: Person A, Person B and 6 other people like this. so i would have to be able to update the like array
b) I want to enable the user to delete comments, hence I will have to pass the array of the remaining comments.
Anyone got suggestions?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
老实说,我不确定我是否理解这个问题,但让我尝试一下。
假设您有充满用户的数据库。因此,我们有(注意,只定义了最少的字段):
用户模型:
状态模型:
StatusComment 模型:
然后您应该有一个文本字段,您可以在其中写入更改视图中的状态。这实际上创建了可以评论的新状态(以便您可以将其与其他状态区分开)。
现在假设您的控制器中有
@user = User.find(params[:id])
。那么在你看来,你应该做类似的事情。我还没有测试过它,但它应该有效,或者至少让你知道该怎么做。
这应该使您能够:
您的表单
您应该澄清a),因为我不知道您想用它做什么。
Honestly I am not sure I understand the question, but let me give it a try.
Let's say you have database full of users. So, we have (notice, only minimal fields are defined):
User model:
Status model:
StatusComment model:
Then you should have a textfield where you write change your status in view. This in reality creates new status which can be commented on (so you can distinguish it from some other status).
Now let's say you have
@user = User.find(params[:id])
in your controller.Then in your view, you should do something like. I have not tested it, but it should work or at least give you a decent idea what to do.
This should enable you to:
your form
You should clarify a) since I have no idea what is it you are trying to do with it.