Hi everyone, im pretty new to ruby/rails and have an issue with the getting started tutorial on http://guides.rubyonrails.org/getting_started.html The model should be extended by this: class Post < ActiveRecord::Base validates :name, :presence => true validates :title, :presence => true, :length => { :minimum => 5} end Now when i enter this into the console p = Post.new(:content => "A new post") i get this: ArgumentError: Range unspecified. Specify the :within, ....... That is not supposed to happen. Rails is 3.0.5, ruby is 1.8.7, so i dont see a problem there.... When i change validates to validate, it creates a record with empty values and saves it (thought of a typo, but obviously wasnt). Im really confused. Does anybode have an idea? Thanks for your help, Gerd -- 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.
Tony Primerano
2011-Mar-17 20:03 UTC
Re: Rails getting started guide: validates not working for me?
The code looks right. Make sure you don''t have class Post defined somewhere else (like post.last.rb). Also, make sure you restart the console each time you make changes to the Post class. Don''t do a reload on the post class from inside the console as this doesn''t work with ActiveRecord last I checked. On Mar 16, 10:53 am, Fluffy <fluffy...-gM/Ye1E23mwN+BqQ9rBEUg@public.gmane.org> wrote:> Hi everyone, > > im pretty new to ruby/rails and have an issue with the getting started > tutorial onhttp://guides.rubyonrails.org/getting_started.html > > The model should be extended by this: > > class Post < ActiveRecord::Base > validates :name, :presence => true > validates :title, :presence => true, > :length => { :minimum => 5} > end > > Now when i enter this into the console > > p = Post.new(:content => "A new post") > > i get this: > ArgumentError: Range unspecified. Specify the :within, ....... > > That is not supposed to happen. Rails is 3.0.5, ruby is 1.8.7, so i > dont see a problem there.... > When i change validates to validate, it creates a record with empty > values and saves it (thought of a typo, but obviously wasnt). > > Im really confused. Does anybode have an idea? > > Thanks for your help, > Gerd-- 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.