Hello all, I've had a problem with my Rails app (apologies if this has been discussed before, I searched and came up empty-handed) I have a Hit model with a "method" field. The problem is that "method" is defined in Object, so doing "hit.method" results in a "wrong number of arguments" error, showing that I'm using Object's method instead of the one ActiveRecord was supposed to define. Any ideas? Is my only option to change the column name? Thanks, Jacob _______________________________________________ Rails mailing list Rails-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org http://lists.rubyonrails.org/mailman/listinfo/rails
I''m not that well versed in rails, but think the best option is to change the column name. I have run into a couple of issues due to my familiarity with java/oracle design. It the end, following the idea of "convention over configuration" turned out to be much easier. Even though there may be a way to do this, I don''t think it would be clean and you would save yourself a lot of time and trouble by just renaming the column. This is, of course, assuming you are starting a new project and have this capability. -- Andrew Stone _______________________________________________ Rails mailing list Rails-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org http://lists.rubyonrails.org/mailman/listinfo/rails
On 9/17/05, Jacob Quinn Shenker <jqshenker-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> is defined in Object, so doing "hit.method" results in a "wrong number > of arguments" error, showing that I''m using Object''s method instead of > the one ActiveRecord was supposed to define. Any ideas? Is my only > option to change the column name?Changing the column name is your _best_ option -- but if you can''t (for whatever reason) change the column name, you can always access the property with the array access method ( hit[ ''method'' ] ).> > Thanks, > Jacob > > _______________________________________________ > Rails mailing list > Rails-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org > http://lists.rubyonrails.org/mailman/listinfo/rails > > >-- Regards, John Wilger ----------- Alice came to a fork in the road. "Which road do I take?" she asked. "Where do you want to go?" responded the Cheshire cat. "I don''t know," Alice answered. "Then," said the cat, "it doesn''t matter." - Lewis Carrol, Alice in Wonderland
(aarrrg! gmail didn't reply to the list!) On 9/18/05, Jacob Quinn Shenker <jqshenker@gmail.com> wrote:> Thanks. > I changed the column name for now, but... > I think it would be helpful the model generator script (and possibly > others) could scan your column names and alert you if you chose a name > already in use. It certainly would have helped me a couple times... > Just an idea! > > Jacob > > On 9/18/05, John Wilger <johnwilger@gmail.com> wrote: > > On 9/17/05, Jacob Quinn Shenker <jqshenker@gmail.com> wrote: > > > is defined in Object, so doing "hit.method" results in a "wrong number > > > of arguments" error, showing that I'm using Object's method instead of > > > the one ActiveRecord was supposed to define. Any ideas? Is my only > > > option to change the column name? > > > > Changing the column name is your _best_ option -- but if you can't > > (for whatever reason) change the column name, you can always access > > the property with the array access method ( hit[ 'method' ] ). > > > > > > > > Thanks, > > > Jacob > > > > > > _______________________________________________ > > > Rails mailing list > > > Rails@lists.rubyonrails.org > > > http://lists.rubyonrails.org/mailman/listinfo/rails > > > > > > > > > > > > > > > -- > > Regards, > > John Wilger > > > > ----------- > > Alice came to a fork in the road. "Which road do I take?" she asked. > > "Where do you want to go?" responded the Cheshire cat. > > "I don't know," Alice answered. > > "Then," said the cat, "it doesn't matter." > > - Lewis Carrol, Alice in Wonderland > > >_______________________________________________ Rails mailing list Rails-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org http://lists.rubyonrails.org/mailman/listinfo/rails
> Changing the column name is your _best_ option -- but if you can''t > (for whatever reason) change the column name, you can always access > the property with the array access method ( hit[ ''method'' ] ).Keep in mind this gets the attribute before type casting. You could alias it if you can''t change the db for some reason def new_column read_attribute ''old_column'' end def new_column=(value) write_attribute ''old_column'', value end -- rick http://techno-weenie.net