Hi all, I have a app with the /tests/new location which renders the add new form. This all works perfectly so when i fill the form in it goes straight into the db but i want the form to store the data in session[:whateverfield] i.e. session[:id], session[:title], session[:name], etc Then pass this the session values to display on a preview info page. Which then the user can edit the session. Once the form is ok then it can be submitting to the db. So i guess the form i have doesn''t need to be changed due to the fields i need are there already but obviously when i press submit button it add the info to the db and not the session, is there something i have to change i.e. the form_for link etc. Any help will be great Thanks -- Posted via http://www.ruby-forum.com/. -- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
On 21 April 2012 12:03, Paul Na <lists-fsXkhYbjdPsEEoCn2XhGlw@public.gmane.org> wrote:> Hi all, > > I have a app with the /tests/new location which renders the add new > form. This all works perfectly so when i fill the form in it goes > straight into the db but i want the form to store the data in > session[:whateverfield] i.e. > > session[:id], session[:title], session[:name], etc > > Then pass this the session values to display on a preview info page. > Which then the user can edit the session. Once the form is ok then it > can be submitting to the db. > > So i guess the form i have doesn''t need to be changed due to the fields > i need are there already but obviously when i press submit button it add > the info to the db and not the session, is there something i have to > change i.e. the form_for link etc.Possibly you want separate controller actions, one that just saves it in the session and one that saves it in the db. Either that or extend the existing actions to do one or the other as appropriate. Colin -- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe@googlegroups.com. For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
Hi Colin, Sorry i understand bits but I''m still new at rails. I see the form action is /tests and the form POSTs i.e. tests GET /tests(.:format) tests#index POST /tests(.:format) tests#create <---- this one POST /tests(.:format) tests#save <-------- new one new_test GET /tests/new(.:format) tests#new edit_test GET /tests/:id/edit(.:format) test#edit test GET /tests/:id(.:format) tests#show PUT /tests/:id(.:format) tests#update DELETE /tests/:id(.:format) tests#destroy root / tests#index So i can create a action save which saves to the session, then the preview just retrieves the session values and links to edit, continue then the last one gives a page to submit the session values to the db with tests#create. Does this sound ok? Also the above routes are not in the routes.rb so where are these stored? Thanks -- Posted via http://www.ruby-forum.com/. -- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
On 21 April 2012 12:52, Paul Na <lists-fsXkhYbjdPsEEoCn2XhGlw@public.gmane.org> wrote:> Hi Colin, > > > Sorry i understand bits but I''m still new at rails. I see the form > action is /tests and the form POSTs i.e. > > tests GET /tests(.:format) tests#index > POST /tests(.:format) tests#create > <---- this one > POST /tests(.:format) tests#save > <-------- new one > new_test GET /tests/new(.:format) tests#new > edit_test GET /tests/:id/edit(.:format) test#edit > test GET /tests/:id(.:format) tests#show > PUT /tests/:id(.:format) tests#update > DELETE /tests/:id(.:format) tests#destroy > root / > tests#index > > > So i can create a action save which saves to the session, then the > preview just retrieves the session values and links to edit, continue > then the last one gives a page to submit the session values to the db > with tests#create. > > Does this sound ok?Sounds good to me> Also the above routes are not in the routes.rb so > where are these stored?I think they probably /are/ in routes.rb, you just don''t realise it. Have a look at the Rails Guide on Routing. Colin -- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe@googlegroups.com. For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
Colin Law wrote in post #1057707:> On 21 April 2012 12:52, Paul Na <lists-fsXkhYbjdPsEEoCn2XhGlw@public.gmane.org> wrote: >> <-------- new one >> preview just retrieves the session values and links to edit, continue >> then the last one gives a page to submit the session values to the db >> with tests#create. >> >> Does this sound ok? > > Sounds good to mecool :)> >> Also the above routes are not in the routes.rb so >> where are these stored? > > I think they probably /are/ in routes.rb, you just don''t realise it. > Have a look at the Rails Guide on Routing. > > ColinAll i have in my routes.rb are: Tests::Application.routes.draw do resources :tests root :to => ''tests#index'' end and that is it. I have had a brief look at it. Thanks for you help -- Posted via http://www.ruby-forum.com/. -- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
On 21/04/2012, Paul Na <lists-fsXkhYbjdPsEEoCn2XhGlw@public.gmane.org> wrote:> Colin Law wrote in post #1057707: >> On 21 April 2012 12:52, Paul Na <lists-fsXkhYbjdPsEEoCn2XhGlw@public.gmane.org> wrote: >>> <-------- new one >>> preview just retrieves the session values and links to edit, continue >>> then the last one gives a page to submit the session values to the db >>> with tests#create. >>> >>> Does this sound ok? >> >> Sounds good to me > > cool :) > >> >>> Also the above routes are not in the routes.rb so >>> where are these stored? >> >> I think they probably /are/ in routes.rb, you just don''t realise it. >> Have a look at the Rails Guide on Routing. >> >> Colin > > All i have in my routes.rb are: > > Tests::Application.routes.draw do > > resources :testsPrecisely. Look at the Rails Guide to see what that means. Colin> > > root :to => ''tests#index'' > > end > > and that is it. I have had a brief look at it. > > Thanks for you help > > -- > Posted via http://www.ruby-forum.com/. > > -- > You received this message because you are subscribed to the Google Groups > "Ruby on Rails: Talk" group. > To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org > To unsubscribe from this group, send email to > rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org > For more options, visit this group at > http://groups.google.com/group/rubyonrails-talk?hl=en. > >-- gplus.to/clanlaw -- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
>> >> Tests::Application.routes.draw do >> >> resources :tests > > Precisely. Look at the Rails Guide to see what that means. >Right ok i have got the new action defined with: resources :tests do post ''save'', :on => :collection end which defines as /tests/save => tests#save then i rake routes and its show up in the routes now :), but the only problem i couldn''t see information unless i''m bind about how to set the form to now submit with the new /tests/save action and not tests#create. Many thanks -- Posted via http://www.ruby-forum.com/. -- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
On 21 April 2012 17:47, Paul Na <lists-fsXkhYbjdPsEEoCn2XhGlw@public.gmane.org> wrote:>>> >>> Tests::Application.routes.draw do >>> >>> resources :tests >> >> Precisely. Look at the Rails Guide to see what that means. >> > > Right ok i have got the new action defined with: > > resources :tests do > post ''save'', :on => :collection > end > > which defines as /tests/save => tests#save > > then i rake routes and its show up in the routes now :), but the only > problem i couldn''t see information unless i''m bind about how to set the > form to now submit with the new /tests/save action and not tests#create.I presume you are using form_for to generate the form. It takes a :url option which you can use to specify a named route. Have a look at the docs for form_for. When you are trying to get it to work look at the html of the page to check it is right. (View > Page Source or similar in your browser). Colin -- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe@googlegroups.com. For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
> > I presume you are using form_for to generate the form. It takes a > :url option which you can use to specify a named route. Have a look > at the docs for form_for. When you are trying to get it to work look > at the html of the page to check it is right. (View > Page Source or > similar in your browser). >Yes i am using form_for. Arh Ok colin i will check that out. Thanks -- Posted via http://www.ruby-forum.com/. -- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.