I got the error wrong argument type String (expected Module) because I was trying to create a select drop down for a field called 'Type'. However, 'Type' is a reserved word and such gains certain behaviours.
The full list of these magic field names reveals as much.
My fix was to simply rename the column. However, that might not always be possible. I found this discussion on the Ruby forums interesting for some alternative suggestions.
About Paul
Paul works for Kyan web design agency in Surrey, UK as a Ruby on Rails developer.
Follow Paul on Twitter
Email: paulsturgess [at] gmail.com
Comments...
Hehe, I was so happy to find the link to this as the first link on google! It could have been a real waste of time! I knew it was reserved but what else to do when you are using single table inheritence?
Alain Pilon at 01 Jun 07 at 22:58
Good man. Thanks you. I keep getting bitten by this stuff.
Rob Dupuis at 11 Sep 07 at 04:26
Just saved me some time too :) thanks
Nico Du Plessis at 17 Feb 08 at 11:30
Gosh, spent several hours trying to fix this one. Wish I had found this site quicker!!
Antony at 17 Apr 08 at 18:05
God, I spent one hour on that problem...thanks for having writted this little note....even if I wish I found it sooner...
Roland at 03 Oct 08 at 08:47
Thanks! Saved me a ton of time potentially.
Denis Ivanov at 05 Jan 09 at 13:30
oh~ Maybe use widget[:type] instead widget.type can solve this error
Raven at 25 Feb 10 at 20:24
To solve this problem I created a virtual attribute and changed the form to reflect the virtual attribute.
In the view erb:
<%= f.select :rtype ... %>
In the model:
def rtype=(strType)
self.type = strType
end
def rtype
return self.type.to_s
end
dhawkins at 11 May 10 at 10:45
Yup, just hit this one. Ta dude.
Pete at 08 Oct 10 at 12:32
Got something to say?