I have a simple crud app. I begin by showing the "find" view where you enter some text (the "searchTerm") which then shows a list of matching rows with a small "Edit" button by each row. When the "Edit" button is clicked the row is then displayed in the "edit" view. On the "edit" form I have a submit button on the form for "update" which will save to the database and run the update method of the controller. Pretty staight forward stuff. The scaffold version of the update method does a redirect to the "show" method after the save. What I would like to do is to redirect(?) back to the find with the searchTerm such that the "found" list of rows is again displayed. So my two questions are: 1) How do I get back to the find with a post (the redirect appears to do a get) and 2) How do I get the "searchTerm" in that post''s parameters? _______________________________________________ Rails mailing list Rails-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org http://lists.rubyonrails.org/mailman/listinfo/rails
On 11/5/05, Richard Williams <sales@planetgps.net> wrote:> I have a simple crud app. > > I begin by showing the "find" view where you enter some text (the > "searchTerm") which then shows a list of matching rows with a small "Edit" > button by each row. > > When the "Edit" button is clicked the row is then displayed in the "edit" > view. > > On the "edit" form I have a submit button on the form for "update" which > will save to the database and run the update method of the controller. > Pretty staight forward stuff. > > The scaffold version of the update method does a redirect to the "show" > method after the save. > > What I would like to do is to redirect(?) back to the find with the > searchTerm such that the "found" list of rows is again displayed. > > So my two questions are: > > 1) How do I get back to the find with a post (the redirect appears to do a > get) andYou wouldn't have to, see below.> > 2) How do I get the "searchTerm" in that post's parameters?You could store the search_term in the user's session, then redirect_to the find action. In the find action, you'd check if you stored a seach_term in the session, and if so, you'd pop that into the initial value of the find box. After all that, you'd probably want to remove the search_term from the session. And note how I used "search_term" instead of "searchTerm"... underscoring is the convention for *variables* in Ruby, the latter for classes (models, controller, etc.). Unless of course I misunderstood you and searchTerm is actually class or model, I don't know why you'd need one however...). Jacob> > > > _______________________________________________ > Rails mailing list > Rails@lists.rubyonrails.org > http://lists.rubyonrails.org/mailman/listinfo/rails > > >_______________________________________________ Rails mailing list Rails-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org http://lists.rubyonrails.org/mailman/listinfo/rails
Ok, that will work. As I see it a redirect will do a "GET" is there any way to do a post instead? Or will a redirect do a post as well? Richard On 11/5/05, Jacob Quinn Shenker <jqshenker-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> On 11/5/05, Richard Williams <sales-9yA49x/h1pUsV2N9l4h3zg@public.gmane.org> wrote: > > I have a simple crud app. > > > > I begin by showing the "find" view where you enter some text (the > > "searchTerm") which then shows a list of matching rows with a small "Edit" > > button by each row. > > > > When the "Edit" button is clicked the row is then displayed in the "edit" > > view. > > > > On the "edit" form I have a submit button on the form for "update" which > > will save to the database and run the update method of the controller. > > Pretty staight forward stuff. > > > > The scaffold version of the update method does a redirect to the "show" > > method after the save. > > > > What I would like to do is to redirect(?) back to the find with the > > searchTerm such that the "found" list of rows is again displayed. > > > > So my two questions are: > > > > 1) How do I get back to the find with a post (the redirect appears to do a > > get) and > > You wouldn''t have to, see below. > > > > > 2) How do I get the "searchTerm" in that post''s parameters? > > You could store the search_term in the user''s session, then > redirect_to the find action. In the find action, you''d check if you > stored a seach_term in the session, and if so, you''d pop that into the > initial value of the find box. After all that, you''d probably want to > remove the search_term from the session. > > And note how I used "search_term" instead of "searchTerm"... > underscoring is the convention for *variables* in Ruby, the latter for > classes (models, controller, etc.). Unless of course I misunderstood > you and searchTerm is actually class or model, I don''t know why you''d > need one however...). > > Jacob > > > > > > > > > _______________________________________________ > > Rails mailing list > > Rails-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org > > http://lists.rubyonrails.org/mailman/listinfo/rails > > > > > > > > _______________________________________________ > Rails mailing list > Rails-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org > http://lists.rubyonrails.org/mailman/listinfo/rails > > >