Return Value On Form Submission in Rails w/ Ajax
So here's what I want to do.
- User fills in the form (Just a textbox and submit)
- The record is added in the background
- The created record's ID i开发者_StackOverflow社区s returned
- A URL (based on the ID) is displayed
How could I go about achieving something like this? Does anyone have any reading material which would help me with it?
Any scaffold will provide you with almost all the code you need to achieve this.
Then add :remote => true
to the form and change slightly the flash message to display resource_name_path(@resource)
精彩评论