Hey there i dont quite know the change of rails 2.0 , but according to Agile Development With Rails, aggregation seem not working....i now create a class like this ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ class Temp attr_reader :n, :p def initialize(n,p) @n = n @p = p end def to_s [@n,@p].compact.join(",") end end ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ now i create a class using ActiveRecord to save to Database, it looks like this: ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ def User<ActiveRecord::Base #next line NO.17 composed_of( :attr, :class_name=>Temp, :mapping=>[[:name , :n], [:password , :p]]) temp = Temp.new("abc","abc") User.create(:attr=> temp) end ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ the problem is some ERROR prompt up : ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ d:/ruby/lib/ruby/gems/1.8/gems/activesupport-2.0.2/lib/active_support/ dependencies.rb:478:in `const_missing'': uninitialized constant User::Temp (NameError) from test.rb:17 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ which indicates the <compose_of> method to be mistaken , i check the rails API, but the the LATEST rails API is 2007 Dec on http://www.rubyonrail.com , is the API Rails 1.X ? Have not updated to rails 2.0 yet? --~--~---------~--~----~------------~-------~--~----~ 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 16 May 2008, at 10:53, stone wrote:> > Hey there > > i dont quite know the change of rails 2.0 , but according to Agile > Development With Rails, aggregation seem not working....i now create a > class like this > ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ > class Temp > attr_reader :n, :p > > def initialize(n,p) > @n = n > @p = p > end > > def to_s > [@n,@p].compact.join(",") > end > end > ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ > now i create a class using ActiveRecord to save to Database, it looks > like this: > ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ > def User<ActiveRecord::Base > #next line NO.17 > composed_of( :attr, :class_name=>Temp, :mapping=>[[:name , :n],:class_name should be the name, ie :class_name => ''Temp'' Also make sure that your Temp class is in temp.rb> [:password , :p]]) > > temp = Temp.new("abc","abc") > User.create(:attr=> temp) > end > ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ > the problem is some ERROR prompt up : > ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ > d:/ruby/lib/ruby/gems/1.8/gems/activesupport-2.0.2/lib/active_support/ > dependencies.rb:478:in `const_missing'': uninitialized constant > User::Temp (NameError) > from test.rb:17 > ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ > which indicates the <compose_of> method to be mistaken , i check the > rails API, but the the LATEST rails API is 2007 Dec on http://www.rubyonrail.com > , is the API Rails 1.X ? Have not updated to rails 2.0 yet?Dec 2007 is when rails 2.0 came out.
You just need modify this line :mapping=>[[:name , :n], [:password , :p]] to :mapping => [["name" , "n"], ["password" , "p"]] On Fri, May 16, 2008 at 5:53 PM, stone <ftaft2000-uAjRD0nVeow@public.gmane.org> wrote:> > Hey there > > i dont quite know the change of rails 2.0 , but according to Agile > Development With Rails, aggregation seem not working....i now create a > class like this > ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ > class Temp > attr_reader :n, :p > > def initialize(n,p) > @n = n > @p = p > end > > def to_s > [@n,@p].compact.join(",") > end > end > ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ > now i create a class using ActiveRecord to save to Database, it looks > like this: > ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ > def User<ActiveRecord::Base > #next line NO.17 > composed_of( :attr, :class_name=>Temp, :mapping=>[[:name , :n], > [:password , :p]]) > > temp = Temp.new("abc","abc") > User.create(:attr=> temp) > end > ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ > the problem is some ERROR prompt up : > ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ > d:/ruby/lib/ruby/gems/1.8/gems/activesupport-2.0.2/lib/active_support/ > dependencies.rb:478:in `const_missing'': uninitialized constant > User::Temp (NameError) > from test.rb:17 > ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ > which indicates the <compose_of> method to be mistaken , i check the > rails API, but the the LATEST rails API is 2007 Dec on > http://www.rubyonrail.com > , is the API Rails 1.X ? Have not updated to rails 2.0 yet? > > >-- Nibirutech CTO Eric.Archangel MSN: archangel_hzm-PkbjNfxxIARBDgjK7y7TUQ@public.gmane.org QQ: 996252 GMAIL: eric.archangel-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org BLOG: http://blog.sina.com.cn/gameloft --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
not working my friend , still the same error On May 16, 6:58 pm, "Eric Archangel" <eric.archan...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> You just need modify this line > :mapping=>[[:name , :n], [:password , :p]] > to > :mapping => [["name" , "n"], ["password" , "p"]] > > > > > > On Fri, May 16, 2008 at 5:53 PM, stone <ftaft2...-uAjRD0nVeow@public.gmane.org> wrote: > > > Hey there > > > i dont quite know the change of rails 2.0 , but according to Agile > > Development With Rails, aggregation seem not working....i now create a > > class like this > > ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ > > class Temp > > attr_reader :n, :p > > > def initialize(n,p) > > @n = n > > @p = p > > end > > > def to_s > > [@n,@p].compact.join(",") > > end > > end > > ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ > > now i create a class using ActiveRecord to save to Database, it looks > > like this: > > ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ > > def User<ActiveRecord::Base > > #next line NO.17 > > composed_of( :attr, :class_name=>Temp, :mapping=>[[:name , :n], > > [:password , :p]]) > > > temp = Temp.new("abc","abc") > > User.create(:attr=> temp) > > end > > ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ > > the problem is some ERROR prompt up : > > ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ > > d:/ruby/lib/ruby/gems/1.8/gems/activesupport-2.0.2/lib/active_support/ > > dependencies.rb:478:in `const_missing'': uninitialized constant > > User::Temp (NameError) > > from test.rb:17 > > ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ > > which indicates the <compose_of> method to be mistaken , i check the > > rails API, but the the LATEST rails API is 2007 Dec on > >http://www.rubyonrail.com > > , is the API Rails 1.X ? Have not updated to rails 2.0 yet? > > -- > Nibirutech CTO Eric.Archangel > MSN: archangel_...-PkbjNfxxIARBDgjK7y7TUQ@public.gmane.org > QQ: 996252 > GMAIL: eric.archan...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org > BLOG:http://blog.sina.com.cn/gameloft- Hide quoted text - > > - Show quoted text ---~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
it''s all in test.rb before i write this , as your suggestion, i put Temp class into temp.rb file,but still not working , still some error : ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ test.rb:2:Warning: require_gem is obsolete. Use gem instead. d:/ruby/lib/ruby/gems/1.8/gems/activerecord-2.0.2/lib/active_record/ aggregations.rb:171:in `x='': undefined method `constantize'' for Temp:Class (NoMethodError) from d:/ruby/lib/ruby/gems/1.8/gems/activerecord-2.0.2/lib/ active_record/base.rb:2117:in `send'' from d:/ruby/lib/ruby/gems/1.8/gems/activerecord-2.0.2/lib/ active_record/base.rb:2117:in `attributes='' from d:/ruby/lib/ruby/gems/1.8/gems/activerecord-2.0.2/lib/ active_record/base.rb:2116:in `each'' from d:/ruby/lib/ruby/gems/1.8/gems/activerecord-2.0.2/lib/ active_record/base.rb:2116:in `attributes='' from d:/ruby/lib/ruby/gems/1.8/gems/activerecord-2.0.2/lib/ active_record/base.rb:1926:in `initialize'' from d:/ruby/lib/ruby/gems/1.8/gems/activerecord-2.0.2/lib/ active_record/base.rb:571:in `new'' from d:/ruby/lib/ruby/gems/1.8/gems/activerecord-2.0.2/lib/ active_record/base.rb:571:in `create'' from test.rb:19 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ line 19 is <%User.create(:x=>temp)%> On May 16, 5:57 pm, Frederick Cheung <frederick.che...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> On 16 May 2008, at 10:53, stone wrote: > > > > > > > > > Hey there > > > i dont quite know the change of rails 2.0 , but according to Agile > > Development With Rails, aggregation seem not working....i now create a > > class like this > > ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ > > class Temp > > attr_reader :n, :p > > > def initialize(n,p) > > @n = n > > @p = p > > end > > > def to_s > > [@n,@p].compact.join(",") > > end > > end > > ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ > > now i create a class using ActiveRecord to save to Database, it looks > > like this: > > ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ > > def User<ActiveRecord::Base > > #next line NO.17 > > composed_of( :attr, :class_name=>Temp, :mapping=>[[:name , :n], > > :class_name should be the name, ie :class_name => ''Temp'' > Also make sure that your Temp class is in temp.rb > > > > > > > [:password , :p]]) > > > temp = Temp.new("abc","abc") > > User.create(:attr=> temp) > > end > > ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ > > the problem is some ERROR prompt up : > > ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ > > d:/ruby/lib/ruby/gems/1.8/gems/activesupport-2.0.2/lib/active_support/ > > dependencies.rb:478:in `const_missing'': uninitialized constant > > User::Temp (NameError) > > from test.rb:17 > > ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ > > which indicates the <compose_of> method to be mistaken , i check the > > rails API, but the the LATEST rails API is 2007 Dec onhttp://www.rubyonrail.com > > , is the API Rails 1.X ? Have not updated to rails 2.0 yet? > > Dec 2007 is when rails 2.0 came out. > > smime.p7s > 5KDownload- Hide quoted text - > > - Show quoted text -- Hide quoted text - > > - Show quoted text ---~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
it''s all in one test.rb before , now the Temp class has moved to temp.rb , but still some errors ,why? ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ test.rb:2:Warning: require_gem is obsolete. Use gem instead. d:/ruby/lib/ruby/gems/1.8/gems/activerecord-2.0.2/lib/active_record/ aggregations.rb:171:in `attr='': undefined method `constantize'' for Temp:Class (NoMethodError) from d:/ruby/lib/ruby/gems/1.8/gems/activerecord-2.0.2/lib/ active_record/base.rb:2117:in `send'' from d:/ruby/lib/ruby/gems/1.8/gems/activerecord-2.0.2/lib/ active_record/base.rb:2117:in `attributes='' from d:/ruby/lib/ruby/gems/1.8/gems/activerecord-2.0.2/lib/ active_record/base.rb:2116:in `each'' from d:/ruby/lib/ruby/gems/1.8/gems/activerecord-2.0.2/lib/ active_record/base.rb:2116:in `attributes='' from d:/ruby/lib/ruby/gems/1.8/gems/activerecord-2.0.2/lib/ active_record/base.rb:1926:in `initialize'' from d:/ruby/lib/ruby/gems/1.8/gems/activerecord-2.0.2/lib/ active_record/base.rb:571:in `new'' from d:/ruby/lib/ruby/gems/1.8/gems/activerecord-2.0.2/lib/ active_record/base.rb:571:in `create'' from test.rb:19 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ which indicates the line <% User.create(:attr=>temp) %> to be mistaken On May 16, 5:57 pm, Frederick Cheung <frederick.che...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> On 16 May 2008, at 10:53, stone wrote: > > > > > > > > > Hey there > > > i dont quite know the change of rails 2.0 , but according to Agile > > Development With Rails, aggregation seem not working....i now create a > > class like this > > ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ > > class Temp > > attr_reader :n, :p > > > def initialize(n,p) > > @n = n > > @p = p > > end > > > def to_s > > [@n,@p].compact.join(",") > > end > > end > > ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ > > now i create a class using ActiveRecord to save to Database, it looks > > like this: > > ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ > > def User<ActiveRecord::Base > > #next line NO.17 > > composed_of( :attr, :class_name=>Temp, :mapping=>[[:name , :n], > > :class_name should be the name, ie :class_name => ''Temp'' > Also make sure that your Temp class is in temp.rb > > > > > > > [:password , :p]]) > > > temp = Temp.new("abc","abc") > > User.create(:attr=> temp) > > end > > ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ > > the problem is some ERROR prompt up : > > ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ > > d:/ruby/lib/ruby/gems/1.8/gems/activesupport-2.0.2/lib/active_support/ > > dependencies.rb:478:in `const_missing'': uninitialized constant > > User::Temp (NameError) > > from test.rb:17 > > ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ > > which indicates the <compose_of> method to be mistaken , i check the > > rails API, but the the LATEST rails API is 2007 Dec onhttp://www.rubyonrail.com > > , is the API Rails 1.X ? Have not updated to rails 2.0 yet? > > Dec 2007 is when rails 2.0 came out. > > smime.p7s > 5KDownload- Hide quoted text - > > - Show quoted text -- Hide quoted text - > > - Show quoted text ---~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
it''s all in one test.rb before , now the Temp class has moved to temp.rb , but still some errors ,why? ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ test.rb:2:Warning: require_gem is obsolete. Use gem instead. d:/ruby/lib/ruby/gems/1.8/gems/activerecord-2.0.2/lib/active_record/ aggregations.rb:171:in `attr='': undefined method `constantize'' for Temp:Class (NoMethodError) from d:/ruby/lib/ruby/gems/1.8/gems/activerecord-2.0.2/lib/ active_record/base.rb:2117:in `send'' from d:/ruby/lib/ruby/gems/1.8/gems/activerecord-2.0.2/lib/ active_record/base.rb:2117:in `attributes='' from d:/ruby/lib/ruby/gems/1.8/gems/activerecord-2.0.2/lib/ active_record/base.rb:2116:in `each'' from d:/ruby/lib/ruby/gems/1.8/gems/activerecord-2.0.2/lib/ active_record/base.rb:2116:in `attributes='' from d:/ruby/lib/ruby/gems/1.8/gems/activerecord-2.0.2/lib/ active_record/base.rb:1926:in `initialize'' from d:/ruby/lib/ruby/gems/1.8/gems/activerecord-2.0.2/lib/ active_record/base.rb:571:in `new'' from d:/ruby/lib/ruby/gems/1.8/gems/activerecord-2.0.2/lib/ active_record/base.rb:571:in `create'' from test.rb:19 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ which indicates the line <% User.create(:attr=>temp) %> to be mistaken On May 16, 5:57 pm, Frederick Cheung <frederick.che...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> On 16 May 2008, at 10:53, stone wrote: > > > > > > > > > Hey there > > > i dont quite know the change of rails 2.0 , but according to Agile > > Development With Rails, aggregation seem not working....i now create a > > class like this > > ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ > > class Temp > > attr_reader :n, :p > > > def initialize(n,p) > > @n = n > > @p = p > > end > > > def to_s > > [@n,@p].compact.join(",") > > end > > end > > ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ > > now i create a class using ActiveRecord to save to Database, it looks > > like this: > > ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ > > def User<ActiveRecord::Base > > #next line NO.17 > > composed_of( :attr, :class_name=>Temp, :mapping=>[[:name , :n], > > :class_name should be the name, ie :class_name => ''Temp'' > Also make sure that your Temp class is in temp.rb > > > > > > > [:password , :p]]) > > > temp = Temp.new("abc","abc") > > User.create(:attr=> temp) > > end > > ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ > > the problem is some ERROR prompt up : > > ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ > > d:/ruby/lib/ruby/gems/1.8/gems/activesupport-2.0.2/lib/active_support/ > > dependencies.rb:478:in `const_missing'': uninitialized constant > > User::Temp (NameError) > > from test.rb:17 > > ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ > > which indicates the <compose_of> method to be mistaken , i check the > > rails API, but the the LATEST rails API is 2007 Dec onhttp://www.rubyonrail.com > > , is the API Rails 1.X ? Have not updated to rails 2.0 yet? > > Dec 2007 is when rails 2.0 came out. > > smime.p7s > 5KDownload- Hide quoted text - > > - Show quoted text -- Hide quoted text - > > - Show quoted text ---~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
Can you show us all of your Temp class please, and the code that you''re using to get that error, and any other model that defines a relationship with the Temp class. It looks possible to me that you''re doing :class_name => Temp, when it should be :class_name => "Temp". I think that''s where I recall getting an error message like that from. -- Appreciated my help? Reccommend me on Working With Rails http://workingwithrails.com/person/11030-ryan-bigg --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
okay this is temp.rb ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ class Temp attr_reader :n, :p def initialize(n,p) @n = n @p = p end def to_s [@n,@p].compact.join(",") end end ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ and this is test.rb ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ require "rubygems" require_gem "activerecord" require "pp" require ''Temp'' ActiveRecord::Base.establish_connection(:adapter=>"mysql",:host=>"localhost",:database=>"test", :encoding=>"utf8",:username=>"root",:password=>"root") class User < ActiveRecord::Base composed_of :attr, :class_name=>Temp, :mapping=>[[:name , :n], [:password , :p]] temp = Temp.new("abc","abc") User.create(:attr => temp) end ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ they are in the same fold ,my seql database have 3 columns , id , name and password , id is unique and key , name and password can be null On May 19, 1:39 pm, "Ryan Bigg (Radar)" <radarliste...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> Can you show us all of your Temp class please, and the code that you''re > using to get that error, and any other model that defines a relationship > with the Temp class. It looks possible to me that you''re doing :class_name > => Temp, when it should be :class_name => "Temp". I think that''s where I > recall getting an error message like that from. > > -- > Appreciated my help? > Reccommend me on Working With Railshttp://workingwithrails.com/person/11030-ryan-bigg--~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
Yup, just as I thought!> composed_of :attr, :class_name=>Temp, :mapping=>[[:name , :n], > [:password , :p]] >This should be :class_name=>"Temp", and then it may work after that. May I ask, what are you trying to achieve with this code? It doesn''t seem very Railsy. -- Appreciated my help? Reccommend me on Working With Rails http://workingwithrails.com/person/11030-ryan-bigg --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
oh no , not again , Railsy or not , anyway , i''m still learning ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ test.rb:2:Warning: require_gem is obsolete. Use gem instead. d:/ruby/lib/ruby/gems/1.8/gems/activerecord-2.0.2/lib/active_record/ base.rb:2177:in `sort'': undefined method `<=>'' for :name:Symbol (NoMethodError) from d:/ruby/lib/ruby/gems/1.8/gems/activerecord-2.0.2/lib/ active_record/base.rb:2177:in `attribute_names'' from d:/ruby/lib/ruby/gems/1.8/gems/activerecord-2.0.2/lib/ active_record/base.rb:2458:in `clone_attributes'' from d:/ruby/lib/ruby/gems/1.8/gems/activerecord-2.0.2/lib/ active_record/base.rb:2126:in `attributes'' from d:/ruby/lib/ruby/gems/1.8/gems/activerecord-2.0.2/lib/ active_record/base.rb:2338:in `attributes_with_quotes'' from d:/ruby/lib/ruby/gems/1.8/gems/activerecord-2.0.2/lib/ active_record/base.rb:2262:in `create_without_callbacks'' from d:/ruby/lib/ruby/gems/1.8/gems/activerecord-2.0.2/lib/ active_record/callbacks.rb:226:in `create_without_timestamps'' from d:/ruby/lib/ruby/gems/1.8/gems/activerecord-2.0.2/lib/ active_record/timestamp.rb:29:in `create'' from d:/ruby/lib/ruby/gems/1.8/gems/activerecord-2.0.2/lib/ active_record/base.rb:2238:in `create_or_update_without_callbacks'' ... 8 levels... from d:/ruby/lib/ruby/gems/1.8/gems/activerecord-2.0.2/lib/ active_record/transactions.rb:120:in `rollback_active_record_state!'' from d:/ruby/lib/ruby/gems/1.8/gems/activerecord-2.0.2/lib/ active_record/transactions.rb:108:in `save'' from d:/ruby/lib/ruby/gems/1.8/gems/activerecord-2.0.2/lib/ active_record/base.rb:572:in `create'' from test.rb:19 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ On May 19, 1:54 pm, "Ryan Bigg (Radar)" <radarliste...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> Yup, just as I thought! > > > composed_of :attr, :class_name=>Temp, :mapping=>[[:name , :n], > > [:password , :p]] > > This should be :class_name=>"Temp", and then it may work after that. > > May I ask, what are you trying to achieve with this code? It doesn''t seem > very Railsy. > -- > Appreciated my help? > Reccommend me on Working With Railshttp://workingwithrails.com/person/11030-ryan-bigg--~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
sorry to say , that still not right after changing ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ test.rb:2:Warning: require_gem is obsolete. Use gem instead. d:/ruby/lib/ruby/gems/1.8/gems/activerecord-2.0.2/lib/active_record/ base.rb:2177:in `sort'': undefined method `<=>'' for :name:Symbol (NoMethodError) from d:/ruby/lib/ruby/gems/1.8/gems/activerecord-2.0.2/lib/ active_record/base.rb:2177:in `attribute_names'' from d:/ruby/lib/ruby/gems/1.8/gems/activerecord-2.0.2/lib/ active_record/base.rb:2458:in `clone_attributes'' from d:/ruby/lib/ruby/gems/1.8/gems/activerecord-2.0.2/lib/ active_record/base.rb:2126:in `attributes'' from d:/ruby/lib/ruby/gems/1.8/gems/activerecord-2.0.2/lib/ active_record/base.rb:2338:in `attributes_with_quotes'' from d:/ruby/lib/ruby/gems/1.8/gems/activerecord-2.0.2/lib/ active_record/base.rb:2262:in `create_without_callbacks'' from d:/ruby/lib/ruby/gems/1.8/gems/activerecord-2.0.2/lib/ active_record/callbacks.rb:226:in `create_without_timestamps'' from d:/ruby/lib/ruby/gems/1.8/gems/activerecord-2.0.2/lib/ active_record/timestamp.rb:29:in `create'' from d:/ruby/lib/ruby/gems/1.8/gems/activerecord-2.0.2/lib/ active_record/base.rb:2238:in `create_or_update_without_callbacks'' ... 8 levels... from d:/ruby/lib/ruby/gems/1.8/gems/activerecord-2.0.2/lib/ active_record/transactions.rb:120:in `rollback_active_record_state!'' from d:/ruby/lib/ruby/gems/1.8/gems/activerecord-2.0.2/lib/ active_record/transactions.rb:108:in `save'' from d:/ruby/lib/ruby/gems/1.8/gems/activerecord-2.0.2/lib/ active_record/base.rb:572:in `create'' from test.rb:19 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ On May 19, 1:54 pm, "Ryan Bigg (Radar)" <radarliste...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> Yup, just as I thought! > > > composed_of :attr, :class_name=>Temp, :mapping=>[[:name , :n], > > [:password , :p]] > > This should be :class_name=>"Temp", and then it may work after that. > > May I ask, what are you trying to achieve with this code? It doesn''t seem > very Railsy. > -- > Appreciated my help? > Reccommend me on Working With Railshttp://workingwithrails.com/person/11030-ryan-bigg--~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
Where are you calling sort? It''s pointing to line 19 in your test.rb, which looks to me to be the call to create. Ok, do you want to make this more railsy? Your models don''t appear to be in a rails directory at all, and the way you are establishing the connection and defining the model in the same file is not very neat. I suggest reading through a Rails tutorial, I''ve begun to write a large one myself and that should kick start you on the path to enlightenment: http://frozenplague.net/forum-guide-getting-started/ Just click through the pages in the right menu, they are in the proper order, ignoring the Frequently Asked Questions and Lovely People pages. --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
in fact I just create a ruby project , include all the lib files , assuming same as a rails project and start my code. On May 19, 2:20 pm, "Ryan Bigg (Radar)" <radarliste...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> Where are you calling sort? It''s pointing to line 19 in your test.rb, which > looks to me to be the call to create. > > Ok, do you want to make this more railsy? Your models don''t appear to be in > a rails directory at all, and the way you are establishing the connection > and defining the model in the same file is not very neat. I suggest reading > through a Rails tutorial, I''ve begun to write a large one myself and that > should kick start you on the path to enlightenment:http://frozenplague.net/forum-guide-getting-started/Just click through the > pages in the right menu, they are in the proper order, ignoring the > Frequently Asked Questions and Lovely People pages.--~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
finally, as Erik the Archangel said , i also change the mapping part , i works now , thank you very much for your help On May 19, 2:29 pm, stone <ftaft2...-uAjRD0nVeow@public.gmane.org> wrote:> in fact I just create a ruby project , include all the lib files , > assuming same as a rails project and start my code. > > On May 19, 2:20 pm, "Ryan Bigg (Radar)" <radarliste...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> > wrote: > > > > > Where are you calling sort? It''s pointing to line 19 in your test.rb, which > > looks to me to be the call to create. > > > Ok, do you want to make this more railsy? Your models don''t appear to be in > > a rails directory at all, and the way you are establishing the connection > > and defining the model in the same file is not very neat. I suggest reading > > through a Rails tutorial, I''ve begun to write a large one myself and that > > should kick start you on the path to enlightenment:http://frozenplague.net/forum-guide-getting-started/Justclick through the > > pages in the right menu, they are in the proper order, ignoring the > > Frequently Asked Questions and Lovely People pages.- Hide quoted text - > > - Show quoted text ---~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
No that''s not how you create a Rails app. You have to firstly generate the skeleton for the rails app. Read through the tutorial, it should teach you a few things. On Mon, May 19, 2008 at 3:59 PM, stone <ftaft2000-uAjRD0nVeow@public.gmane.org> wrote:> > in fact I just create a ruby project , include all the lib files , > assuming same as a rails project and start my code. > > On May 19, 2:20 pm, "Ryan Bigg (Radar)" <radarliste...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> > wrote: > > Where are you calling sort? It''s pointing to line 19 in your test.rb, > which > > looks to me to be the call to create. > > > > Ok, do you want to make this more railsy? Your models don''t appear to be > in > > a rails directory at all, and the way you are establishing the connection > > and defining the model in the same file is not very neat. I suggest > reading > > through a Rails tutorial, I''ve begun to write a large one myself and that > > should kick start you on the path to enlightenment: > http://frozenplague.net/forum-guide-getting-started/Just click through the > > pages in the right menu, they are in the proper order, ignoring the > > Frequently Asked Questions and Lovely People pages. > > >-- Appreciated my help? Reccommend me on Working With Rails http://workingwithrails.com/person/11030-ryan-bigg --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---