[英]Rails - Creating records with best in place gem
I have Items and Plans associated to those items 我有与这些项目相关的项目和计划
item.rb item.rb的
name: string
cost: float
plan.rb plan.rb
belongs_to: Item
percentage: float
month: integer
year: integer
I'm building a table where I want to edit and create plans. 我正在构建一个表,我想编辑和创建计划。 Something like this
像这样的东西
Item Jan 14 Feb 14 ... Jan 15 Feb 15 01 10% 12% 15% 20% //Each column represents 02 0%* 12% 0%* 20% //a plan 03 23% 12% 15% 0%*
I'm using best in place gem to update those percentage and it works perfect. 我正在使用最好的宝石来更新这些百分比,它的工作完美。 My problem is when a plan is not already created (the ones marked with *).
我的问题是什么时候还没有创建计划(标有*的计划)。
Is there a way to use best in place to fire an ajax call with POST method to create plans? 有没有办法使用最好的方法来使用POST方法触发ajax调用来创建计划?
I could create plans for all the items before the table is displayed, but that's not my intention. 我可以在显示表格之前为所有项目创建计划,但这不是我的意图。 Probably best in place it's not the best option and I should try another strategy.
可能是最好的,它不是最好的选择,我应该尝试另一种策略。
I had the same problem and came across this pull request on the best in place gem: 我有同样的问题,并在最好的宝石上遇到了这个拉取请求:
Pull Request: https://github.com/bernat/best_in_place/pull/527 请求: https : //github.com/bernat/best_in_place/pull/527
Branch: https://github.com/sbeam/best_in_place 分支机构: https : //github.com/sbeam/best_in_place
It provides the ability to create new records with BIP and is working for my project. 它提供了使用BIP创建新记录的功能,并且正在为我的项目工作。 You can wait for it to be merged or install the branch by using this in the gemfile:
您可以等待它合并,或者在gemfile中使用它来安装分支:
gem 'best_in_place', github: 'sbeam/best_in_place'
Unfortunately, there's no documentation on it yet, but the pull request files show how it can be used. 不幸的是,还没有关于它的文档,但是pull请求文件显示了如何使用它。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.