I am a newbie at RoR so thank you for your patients. I have a form with the following fields: 1. first_name 2. last_name I want to take them and make them into one variable "name" and submit that to my table field named "name". Can anyone help? Thank you, Sean McGilvray --~--~---------~--~----~------------~-------~--~----~ 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-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
Haii For this case.. a lot of way... 1. make name in model --> this is the best way 2. make name in controller -> this is good way *way no 1* in model attr_accessor :first_name attr_accessor :last_name def before_save self.name = @first_name + " " + @last_name end in controller def save user = User.new() user.first_name = params[:first_name] user.last_name = params[:last_name] user.save end *way no 2* For example model user, controller costumer in controller def save user = User.new user.name = params[:first_name] + " " + params[:last_name] user.save end I hope it will help you.. Thank you On Fri, Jan 30, 2009 at 7:22 AM, Sean McGilvray <smcgilvray-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>wrote:> > I am a newbie at RoR so thank you for your patients. > > I have a form with the following fields: > 1. first_name > 2. last_name > > I want to take them and make them into one variable "name" and submit > that to my table field named "name". Can anyone help? > > Thank you, > > Sean McGilvray > > >-- Wu You Duan --~--~---------~--~----~------------~-------~--~----~ 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-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
This is exactly what I was looking for. Thank you, Sean McGilvray & Sarena Byers Director Identity Theft Specialist Pre-Paid Legal Service''s, Inc. NYSE:PPD Phone: 760-486-1019 smcgilvray-C6gt8ZI8z3bIY2DP0bkpxA@public.gmane.org http://www.transferhome.net On Thu, Jan 29, 2009 at 6:59 PM, anton effendi <wuyouduan-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> Haii > For this case.. a lot of way... > 1. make name in model --> this is the best way > 2. make name in controller -> this is good way > > *way no 1* > in model > > attr_accessor :first_name > attr_accessor :last_name > > def before_save > self.name = @first_name + " " + @last_name > end > > > in controller > > def save > user = User.new() > user.first_name = params[:first_name] > user.last_name = params[:last_name] > user.save > end > > > > *way no 2* > For example model user, controller costumer > in controller > > def save > user = User.new > user.name = params[:first_name] + " " + params[:last_name] > user.save > end > > > > I hope it will help you.. > Thank you > > > > > On Fri, Jan 30, 2009 at 7:22 AM, Sean McGilvray <smcgilvray-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>wrote: > >> >> I am a newbie at RoR so thank you for your patients. >> >> I have a form with the following fields: >> 1. first_name >> 2. last_name >> >> I want to take them and make them into one variable "name" and submit >> that to my table field named "name". Can anyone help? >> >> Thank you, >> >> Sean McGilvray >> >> > > > -- > Wu You Duan > > > >--~--~---------~--~----~------------~-------~--~----~ 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-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---