Thanks once again. I'm sorry for giving you the trouble to scroll down to see the query that I was referring to. I am quite new to nabble. henceforth, I'll make it a point to top post such things
Colin Law-4 wrote: > > On 8 March 2010 03:38, mamathahl <[email protected]> wrote: >> >> Colin, this is in a migration. >> But I did not understand the last para of your reply. > > Have a look at > http://groups.google.com/group/rubyonrails-talk/browse_thread/thread/f23f96c71facf726 > for a discussion on why it is not a good idea to seed in migrations. > Also google for 'rails migration seed' will provide many hits. > > Could you not top post please? If you had put the above query under > the offending paragraph we would not have had to scroll down to find > to what you were referring. Thanks. > > Colin > > As you have suggested, >> I will first try it on script/console and den let me try to know where >> exactly the error is happening. >> >> Colin Law-4 wrote: >>> >>> On 7 March 2010 00:39, mamathahl <[email protected]> wrote: >>>> >>>> I have been facing some problem with the datatypes. I have a sample of >>>> code >>>> as follows. >>>> >>>> t.lat_rad = (l.lat * BigDecimal.new("3.1415926536 / 180")).to_f >>>> t.lng_rad = (l.lng * BigDecimal.new("3.1415926536 / 180")).to_f >>>> >>>> Initially, the datatype of lat_rad and lng_rad was as follows: >>>> >>>> t.decimal :lat_rad, :precision => 15, :scale => 10 >>>> t.decimal :lng_rad, :precision => 15, :scale => 10 >>>> >>>> So, it gave me an error as follows: >>>> >>>> TypeError in ItemsController#populate >>>> >>>> wrong argument type BigDecimal (expected Float) >>>> >>>> Then I changed the data type of lat_rad and lng_rad to float. Even >>>> then >>>> it >>>> is giving me the same error. Any help to solve this problem will be >>>> appreciated. Thanks in advance. >>> >>> I would suggest first splitting the statement into several lines >>> performing a single operation on each line, this will enable you to >>> identify which part of the statement is generating the error. Also >>> try playing in ruby console to try and see what is going on. Finally >>> you could use ruby-debug to break in to the code and examine the types >>> of the variables to find what may not be quite as you expect. >>> >>> Also you did not answer the question as to whether this is in a >>> migration. If so then it fraught with problems, it is not advisable >>> to seed data within a migration if that is what you are doing. >>> >>> 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 [email protected]. >>> To unsubscribe from this group, send email to >>> [email protected]. >>> For more options, visit this group at >>> http://groups.google.com/group/rubyonrails-talk?hl=en. >>> >>> >>> >> >> -- >> View this message in context: >> http://old.nabble.com/datatype-error-in-ROR-tp27808361p27816821.html >> Sent from the RubyOnRails Users mailing list archive at Nabble.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 [email protected]. >> To unsubscribe from this group, send email to >> [email protected]. >> 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 [email protected]. > To unsubscribe from this group, send email to > [email protected]. > For more options, visit this group at > http://groups.google.com/group/rubyonrails-talk?hl=en. > > > -- View this message in context: http://old.nabble.com/datatype-error-in-ROR-tp27808361p27825847.html Sent from the RubyOnRails Users mailing list archive at Nabble.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 [email protected]. To unsubscribe from this group, send email to [email protected]. For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.

