Hello, can someone help, please, how to work with Active Record? I''m trying under this page -http://guides.rubyonrails.org/active_record_querying.html#retrieving-a-single-object - building query on database, but I''m getting errors always, when I try to use some command except .new, .save, .find, .all. in application.rb I have: require "active_record/railtie" require "action_controller/railtie" require "action_mailer/railtie" require "active_resource/railtie" require "rails/test_unit/railtie" in my model I have: class Example < ActiveRecord::Base include MongoMapper::Document key :name end And now if I try: exam= Example.order("name_at ASC") #--> undefined method `spec'' for nil:NilClass (that is in a view) exam= Example.all I guess everything for work with AR is ready, but I don''t now, why commands as .order, .where, .first etc not works... :( I''m using Rails 3.0.5 and MongoDB. -- 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.
On Apr 1, 3:21 pm, Manny 777 <li...-fsXkhYbjdPsEEoCn2XhGlw@public.gmane.org> wrote:> Hello, > > can someone help, please, how to work with Active Record? > I''m trying under this page > -http://guides.rubyonrails.org/active_record_querying.html#retrieving-... > - building query on database, but I''m getting errors always, when I try > to use some command except .new, .save, .find, .all. > > in application.rb I have: > > require "active_record/railtie" > require "action_controller/railtie" > require "action_mailer/railtie" > require "active_resource/railtie" > require "rails/test_unit/railtie" > > in my model I have: > > class Example < ActiveRecord::Base > include MongoMapper::Document > key :name > end > > And now if I try: > > exam= Example.order("name_at ASC") #--> undefined method `spec'' for > nil:NilClass (that is in a view) > > exam= Example.all > > I guess everything for work with AR is ready, but I don''t now, why > commands as .order, .where, .first etc not works... :( > > I''m using Rails 3.0.5 and MongoDB.If you''re using mongodb then your class shouldn''t be inheriting from ActiveRecord. Skip straight pass the active record documentation and read up on mongomapper (or whatever mongo adapter you fancy using - mongoid is another popular one) Fred> > -- > Posted viahttp://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@googlegroups.com. For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
Thanks Fred, at least I know, what to search... I have that feeling I am solving problems with gems, plugins, interfaces instead programming of apps... Not funny. -- 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.