hi i m new to ROR..........I want to save my data in my table..... i created form like this............... <% form_tag :action => "create" do %> <p>User Name : <%= text_field ''user'', ''name'' %></p> <p>Password : <%= password_field ''user'', ''password'' %></p> <%= submit_tag "Create New User"%> <% end %> ---------------------------------------------------------------- and in usercontroller ............. def new @user = User.new end def create @user = User.new(params[:user]) if @user.save redirect_to :action => ''list'' else redirect_to :action => ''new'' end end ----------------------------------------------------------------- there is no error but my data is not saved??????????? help me -- 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-/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 -~----------~----~----~----~------~----~------~--~---
On Apr 25, 2:26 pm, Manish Nautiyal <rails-mailing-l...-ARtvInVfO7ksV2N9l4h3zg@public.gmane.org> wrote:> hi i m new to ROR..........I want to save my data in my table..... > > i created form like this............... > > <% form_tag :action => "create" do %> > <p>User Name : <%= text_field ''user'', ''name'' %></p> > <p>Password : <%= password_field ''user'', ''password'' %></p> > <%= submit_tag "Create New User"%> > <% end %> > ---------------------------------------------------------------- > and in usercontroller ............. > > def new > @user = User.new > end > > def create > @user = User.new(params[:user]) > if @user.save > redirect_to :action => ''list'' > else > redirect_to :action => ''new'' > end > end > ----------------------------------------------------------------- > > there is no error but my data is not saved??????????? > help me > -- > Posted viahttp://www.ruby-forum.com/.Did you check your log files? If you''re on Rails 2.0 and following general RESTful design, this series might help: http://softiesonrails.com/search?q=forms+in+rails Jeff softiesonrails.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-/JYPxA39Uh5TLH3MbocFFw@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 -~----------~----~----~----~------~----~------~--~---
Jeff Cohen wrote:> On Apr 25, 2:26�pm, Manish Nautiyal <rails-mailing-l...@andreas-s.net> > wrote: >> and in usercontroller ............. >> � � � � � � redirect_to :action => ''new'' >> � � � end >> � end >> ----------------------------------------------------------------- >> >> there is no error but my data is not saved??????????? >> help me >> -- >> Posted viahttp://www.ruby-forum.com/. > > Did you check your log files? > > If you''re on Rails 2.0 and following general RESTful design, this > series might help: http://softiesonrails.com/search?q=forms+in+rails > > Jeff > softiesonrails.comI m new.......... so wht should i check in log files........????? -- 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-/JYPxA39Uh5TLH3MbocFFw@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 m new.......... > so wht should i check in log files........?????When you call your create method in your user_controller look to see if there are any errors being thrown when you say @user.save. Where does your page redirect to when you try and save the user information? It looks like to me that if your save goes bad than you will be redirected to the "new" page. Is that what it is doing? Usually any errors in your log file will be noticable - they will be long and print out a trace stack of where the error occured. Good luck, -Shandy -- 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-/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 -~----------~----~----~----~------~----~------~--~---
Thanx Shandy........... :) -- 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-/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 -~----------~----~----~----~------~----~------~--~---
I think I have a more simplified (fundamental) question on this subject. I went to the irb using ''script/console'' in my rails app. I created a new record by typing the following:> city = City.new #City is the name of my class I recently created> city.name = ''Murray''> city.population = 78000#I''ve omitted the irb responses #everything looks fine when I ask> city #it returns the values assigned to the table columns ''name'' and ''population''#My problem is when I type> city.save #it returns false when I expected true!#at first, I thought it may be because I need to su in as root to save the changes, but not the case. I am using Suse 10.3, Rails 2.0, and mysql 5.0 any ideas? -- 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-/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 -~----------~----~----~----~------~----~------~--~---
On 23 May 2008, at 13:07, Jason Lillywhite wrote:> > #I''ve omitted the irb responses > > #everything looks fine when I ask > >> city #it returns the values assigned to the table columns ''name'' >> and ''population'' > > #My problem is when I type > >> city.save #it returns false when I expected true! > > #at first, I thought it may be because I need to su in as root to save > the changes, but not the case. I am using Suse 10.3, Rails 2.0, and > mysql 5.0 >you''ve probaly got some validations preventing saving. After city.save has returned false, check city.errors Fred> any ideas? > -- > 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-/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 -~----------~----~----~----~------~----~------~--~---
You are right. I forgot about my validations. Thanks for pointer on city.errors -- 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-/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 -~----------~----~----~----~------~----~------~--~---