我使用 ruby script/generate scaffold subject name:string desc:string 命令创建了一个简单的 Rails 页面。
现在,我可以以RESTful的方式添加、编辑和删除主题。
What I like to do is changing above behavior as Ajax way. Everything can be done in index page. For example...this is the page throw the browser~
屏幕1
Listing subjects
name desc
test1 test1 show edit destroy
test2 test2 show edit destroy
[___] [___] create
如果您点击编辑链接,页面将会像下面这样转换
屏幕2
Listing subjects
name desc
[test1] [test1] update <-------- this !!! text_field !
test2 test2 show edit destroy
And you can change name and desc. After change the values, clicking update link will update it and browser will display similar page with 屏幕1
此外,您可以通过在列表底部填写空白文本字段并点击创建链接来添加新主题。它会立即应用。
我试图找出这个问题的答案,但是Railscasts和其他一些网页都没有帮助。 :(
Do anybody know where the sample code for this is or please write simple one !!! I really appreciate it if you do so...........