Steve Mr.
2011-Nov-26 19:09 UTC
New rails user - Trying to understand why console wont run save command
Hi Everyone, I just found this forum today and I''m having trouble with a rails tutorial I''m working on. On all other rails console commands it runs when I hit enter such as: ">> subject.new_record? => true" However when I try to save a record using:>> subject = Subject.new(:name => "First Subject", :position => 1", :visible =>true) Nothing happens. I tried create as well. When I hit enter it just puts an enter and doesn''t run the command which returns. Any clue what I''m doing wrong? -- 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.
Dave Aronson
2011-Nov-26 19:26 UTC
Re: New rails user - Trying to understand why console wont run save command
On Sat, Nov 26, 2011 at 14:09, Steve Mr. <lists-fsXkhYbjdPsEEoCn2XhGlw@public.gmane.org> wrote:> On all other rails console commands it runs > when I hit enter such as: > > ">> subject.new_record? > => true" > > However when I try to save a record using: > >>> subject = Subject.new(:name => "First Subject", :position => 1", :visible => > true)That won''t save a record. It will only create an object. To save it as a database record, you need to do subject.save -- and that also assumes that the class inherits from ActiveRecord, you''ve created the table in the database, etc.> Nothing happens. I tried create as well. When I hit enter it just puts > an enter and doesn''t run the command which returns. Any clue what I''m > doing wrong?Does it do absolutely nothing, not even tell you something like: => #<Subject:0x00000100a218a8 name="dave", position="reclining", visible=true> ? That is indeed odd. Can you post the code of the class, at least the initializer? -Dave -- LOOKING FOR WORK! What: Ruby (on/off Rails), Python, other modern languages. Where: Northern Virginia, Washington DC (near Orange Line), and remote work. See: davearonson.com (main) * codosaur.us (code) * dare2xl.com (excellence). Specialization is for insects. (Heinlein) - Have Pun, Will Babble! (Aronson) -- 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.
Fernando Almeida
2011-Nov-26 19:28 UTC
Re: New rails user - Trying to understand why console wont run save command
Subject.new only create a new object in memory, to persist in the database you should to use subject.save or directly Subject.create(:name => "First Subject", :position => 1", :visible => true) 2011/11/26 Steve Mr. <lists-fsXkhYbjdPsEEoCn2XhGlw@public.gmane.org>> Hi Everyone, > > I just found this forum today and I''m having trouble with a rails > tutorial I''m working on. On all other rails console commands it runs > when I hit enter such as: > > ">> subject.new_record? > => true" > > However when I try to save a record using: > > >> subject = Subject.new(:name => "First Subject", :position => 1", > :visible => > true) > > Nothing happens. I tried create as well. When I hit enter it just puts > an enter and doesn''t run the command which returns. Any clue what I''m > doing wrong? > > -- > 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. > >-- Fernando Almeida www.fernandoalmeida.net -- 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.
Michael Pavling
2011-Nov-26 19:31 UTC
Re: New rails user - Trying to understand why console wont run save command
On 26 November 2011 19:09, Steve Mr. <lists-fsXkhYbjdPsEEoCn2XhGlw@public.gmane.org> wrote:> However when I try to save a record using: > >>> subject = Subject.new(:name => "First Subject", :position => 1", :visible => > true) > > Nothing happens.You''ve got an extra quote in there after :position... -- 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.
Steve Mr.
2011-Nov-26 19:43 UTC
Re: New rails user - Trying to understand why console wont run save command
wow. The quote was the issue. Unbelievable. Thanks. I''m back to cranking out this tutorial -- 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
2011-Nov-26 20:36 UTC
Re: Re: New rails user - Trying to understand why console wont run save command
On 26 November 2011 19:43, Steve Mr. <lists-fsXkhYbjdPsEEoCn2XhGlw@public.gmane.org> wrote:> wow. The quote was the issue. Unbelievable. Thanks. I''m back to cranking > out this tutorialThe reason it did not do anything was because you had not entered a complete statement (the extra quote meant that the last stuff on the line appeared to be a quoted string) so it was waiting for you to enter the rest of the statement. I imagine it prompted you with a > or similar. 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.
<subbarao.kly-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
2011-Nov-27 04:19 UTC
Re: New rails user - Trying to understand why console wont run save command
After you have to save the orm records to database by .save! Comand . Ex:- subject.save! Comand ---------- Sent from my Nokia phone ------Original message------ From: Steve Mr. <lists-fsXkhYbjdPsEEoCn2XhGlw@public.gmane.org> To: <rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org> Date: Saturday, November 26, 2011 8:09:41 PM GMT+0100 Subject: [Rails] New rails user - Trying to understand why console wont run save command Hi Everyone, I just found this forum today and I''m having trouble with a rails tutorial I''m working on. On all other rails console commands it runs when I hit enter such as: ">> subject.new_record? => true" However when I try to save a record using:>> subject = Subject.new(:name => "First Subject", :position => 1", :visible =>true) Nothing happens. I tried create as well. When I hit enter it just puts an enter and doesn''t run the command which returns. Any clue what I''m doing wrong? -- 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. -- 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.