2009/9/2 Quee Mm <[email protected]>: > > Well it turns out that it was a string vs integer issue. I have my > fields in db as string and the code was generating a integer so that > caused issues at edit time. > > I made the following change and now it seems to work. > > <%= f.select(:year_made, ((1980..Time.now.year).collect {|p| [ p.to_s, > p.to_s ]}).reverse, {:prompt=>"Select a Year"}) %> > > Does anyone else have a better idea on how to do this?
You probably only need the to_s on one of them not both. Presumably it would also work if, instead, the type of year_made were changed to integer. Arguably this might be a more aesthetically pleasing solution. Colin > > --------------------------- > > Colin Law wrote: >> 2009/8/31 Quee Mm <[email protected]>: >>> For Edit >>> http://pastie.org/600226 >>> >>> >>>> Have you checked that year_made contains the previous value. Possibly >>>> put <%= @object.year_made %> in the form to check. >>> Yes it does. >> >> Odd, it all looks ok to me. Is year_made an integer or a string? I >> wonder whether it is expecting an integer as all my uses have always >> been with an id value. >> >> Any other ideas anyone? >> >> Colin > > -- > 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 [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 -~----------~----~----~----~------~----~------~--~---

