在两个以前添加的帖子之间创建帖子 - Ruby on Rails

时间:2017-03-19 17:27:38

标签: ruby-on-rails

我正在构建一个Web应用程序,如果有人可以提供帮助,我会遇到技术问题。

我的应用有一个帖子模型。我希望用户能够在之前添加的两个帖子之间添加帖子。

例如:在视图中会出现以下帖子:

"this is the first post"
"this is the second post"
"this is the third post"
"this is the fourth post"

我希望用户能够在第一篇和第二篇文章之间添加帖子,以便视图显示:

"this is the first post"
"This is the last added post"
"this is the second post"
"this is the third post"
"this is the fourth post"

任何人都知道如何解决这个问题?

1 个答案:

答案 0 :(得分:1)

我建议使用acts_as_list gem。

如果需要,您还可以使用position列,并在添加新位置时更新所有位置。