Babos Cata
2010-Feb-12 19:02 UTC
Form data transfer to another form with a different controle
Hi, I`m just learning how Ruby on Rails works. So I`m just wondering if you can transfer data from a form to another form with a different controller. I got a simple form like this on the ''site'' controller: <% form_for :user do |form| %> <%= form.text_field :Nick %> <%= form.text_field :Name %> <%= form.text_field :Email %> <%= submit_tag "Next", :class => "submitb" %> <% end %> I don`t know what to write in the SiteController. I want to send the data to another form on the ''user'' controler. Is it possible ? Regards -- 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.
Sharagoz --
2010-Feb-12 20:24 UTC
Re: Form data transfer to another form with a different controle
This question is so basic that you really need to get a RoR book. (Like "Agile Development with Rails". I dont mean that in a bad way. You''re gonna have a bunch of similar questions while getting you bearings with RoR, and asking on the RoR lists every time is not a good solution. Anyway, to answer your question <% form_for(:user, :url => {:controller => ''the_other_controller'', :action => ''the_other_controllers_action''}) do |form| %> No code needed in the sites controller, as the form can be posted directly to a controller of your choice. (not even gonna mention REST) -- 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.
Babos Cata
2010-Feb-12 22:02 UTC
Re: Form data transfer to another form with a different controle
Thank you very much :) I don`t know what I was thinking.. this is easy indeed. Regards -- 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.
Babos Cata
2010-Feb-15 15:44 UTC
Re: Form data transfer to another form with a different controle
The forms work well, but now when I transfer the values form the first form to the second one, it automatically validates the fields. I don`t want that. It should validate them when I try to submit the data from the second form. What should I do ? Do I need to change some validation in the model? -- 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.
Colin Law
2010-Feb-15 15:52 UTC
Re: Re: Form data transfer to another form with a different controle
On 15 February 2010 15:44, Babos Cata <lists-fsXkhYbjdPsEEoCn2XhGlw@public.gmane.org> wrote:> The forms work well, but now when I transfer the values form the first > form to the second one, it automatically validates the fields. I don`t > want that. It should validate them when I try to submit the data from > the second form. > > What should I do ? Do I need to change some validation in the model?I don''t understand what you mean by transferring data from one form to another, but validation happens when an attempt is made to save to the database, it is nothing to do with forms (except that often the data has come from a form). Presumably you are saving the data as you transfer it, which I gather you do not wish to do. If you look in development.log you may get a better idea of what is happening. I also wonder whether you are missing some fundamental concepts of Rails. Have you worked through some of the guides at http://guides.rubyonrails.org/, particularly Getting Started, Debugging, and ActiveRecord associations? 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-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
Babos Cata
2010-Feb-15 17:33 UTC
Re: Re: Form data transfer to another form with a different controle
It seems like the first form sends data to the database using the second form (beeing wierd), insted of simply sending data to the second form. -- 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.
Colin Law
2010-Feb-15 21:00 UTC
Re: Re: Re: Form data transfer to another form with a different controle
On 15 February 2010 17:33, Babos Cata <lists-fsXkhYbjdPsEEoCn2XhGlw@public.gmane.org> wrote:> It seems like the first form sends data to the database using the second > form (beeing wierd), insted of simply sending data to the second form.What do you mean ''sending data to the second form''? When a form is submitted the data goes to a controller action, it cannot go direct to another form. Did you have a look (and I mean a work through not just a glance) at the guides as I suggested? They may make it all more clear. It is better not to remove all the context from the mail you are replying to so that each post makes some sort of sense in case the threading gets lost, as it does sometimes. 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-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
Babos Cata
2010-Feb-15 21:21 UTC
Re: Re: Re: Form data transfer to another form with a different controle
Colin Law wrote:> On 15 February 2010 17:33, Babos Cata <lists-fsXkhYbjdPsEEoCn2XhGlw@public.gmane.org> wrote: >> It seems like the first form sends data to the database using the second >> form (beeing wierd), insted of simply sending data to the second form. > > What do you mean ''sending data to the second form''? When a form is > submitted the data goes to a controller action, it cannot go direct to > another form. > > Did you have a look (and I mean a work through not just a glance) at > the guides as I suggested? They may make it all more > clear. > > It is better not to remove all the context from the mail you are > replying to so that each post makes some sort of sense in case the > threading gets lost, as it does sometimes. > > ColinThank you again for you fast reply. Indeed I started working with some basic forms and debugging methods. I tried some examples but non works, yet. I want something like the simple php function, fill a form then send the values from the input tags in another form. So I got a simple register from on the index(site controller) page with 3 text_field, when submitted the values from the text_fields should be send in the second form(user controller), a bigger register form. Only when I submit the user controller register form, the values should be send to the database. Regards -- 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.
Babos Cata
2010-Feb-15 21:41 UTC
Re: Re: Re: Form data transfer to another form with a different controle
> Thank you again for you fast reply. Indeed I started working with some > basic forms and debugging methods. I tried some examples but non works, > yet. > > I want something like the simple php function, fill a form then send the > values from the input tags in another form. > > So I got a simple register from on the index(site controller) page with > 3 text_field, when submitted the values from the text_fields should be > send in the second form(user controller), a bigger register form. Only > when I submit the user controller register form, the values should be > send to the database. > > RegardsThink I got it. The user controller: def register @title = "register" if param_posted?(:user) @user = User.new(params[:user]) < some code that says: stop running code, onClick submit button continue code > if @user.save @user.connect!(session) flash[:notice] = "" redirect_to_forwarding_url else @user.clear_password! end end end Looking into it. -- 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.
Babos Cata
2010-Feb-16 22:05 UTC
Form data transfer to another form with a different controle
Sigh.. nothing works. I`ll abandone all this. -- 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.
Sharagoz --
2010-Feb-16 22:27 UTC
Re: Form data transfer to another form with a different controle
> Sigh.. nothing works. I`ll abandone all this.Hang in there a little longer. If you want the user to first fill in 3 fields, then proceed to another form to fill out the rest of the fields it will look something like this: (You got the first part working, and the 3 fields are submitted to the controller, right?) the controller action that receives those parameters will need to render a new form, which are then submitted to a second controller action. you could use the same controller action for both steps, but lets use two for simplicity. in the controller: def register_1 #Receives the first 3 fields @user = User.new(params[:user]) #Now register_1.html are rendered end register_1.html must now contain a form looking something like this: <% form_for(@user, :url => {:action => ''register_2''}) do |form| %> #Because the user is not saved in step 1, this form must contain hidden fields with the value of the fields from step_1 <%= form.hidden_field(:name) %> #etc #Put the rest of the fields here, just like in the first form <% end %> The second controller action receives the complete user info and saves the user def register_2 @user = User.create(params[:user]) #Maybe a flash and a redirect here end Rails uses the MVC architecture, so you need to learn how the models, controllers and views interact before you start getting the hang of it. -- 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.