This project is archived and is in readonly mode.

#4778 ✓invalid
Francis Fish

Can't create a model called Task - conflicts with Rake::Task??

Reported by Francis Fish | June 6th, 2010 @ 05:21 PM

Just moved from 2.3.5 to 2.3.8 and suddenly whenever I try to access a model called task I get:

undefined method quoted_table_name' for Rake::Task:Class

I set the referencing class to be use :class_name => '::Task' and then got

WARNING: Deprecated reference to top-level constant 'Task' found at: /usr/local/lib/ruby/gems/1.8/gems/rake-0.8.7/lib/rake.rb:2470:in rakefile_location'

I think the order that things are being loaded is preventing Ruby from autoloading the task model, or there's some overzealous class paranoia in Rake now. If I explicitly load task.rb then it works in the console.

The class that has tasks associated with it works if you load task.rb, which is what I've done to get around it.

Not sure if this is also in 3.x because not using it yet.

Comments and changes to this ticket

  • Jeff Dean

    Jeff Dean June 9th, 2010 @ 06:11 AM

    This has happened to me in the past when loading a gem or plugin that requires rake. For example whenever.

    If you are using bundler, you may have to add :require => false, then manually require that gem after the rails initializer block in environment.rb.

    I'd check your gems / plugins first, and make sure none are requiring rake as the next debugging step.

  • Neeraj Singh

    Neeraj Singh June 25th, 2010 @ 09:55 PM

    How are you trying to access Task. I created a scaffold for Task and it is working fine for me at both 2-3-stable and rails edge.

  • Francis Fish

    Francis Fish June 26th, 2010 @ 11:57 AM

    • Importance changed from “” to “Low”

    It went away when I switched back to 2.3.5 and I haven't been chasing it since.

    I've just dug through my git repo back to where I switched back and the problem isn't showing - must be some environmental thing that's been fixed since.

    If I cant show you you can't look at it.

    For the record, a fragment had many tasks and it was initialising fragments that caused the problem, looked like they hadn't been loaded, and when it was trying to load them it was finding the rake class first.

    So you may as well close the log unless you can get it to choke with a new 2.3.5 and no later installs.

    Currently running rake 0.8.7, which may be why it's working now.

    Thank you.

  • Rohit Arondekar

    Rohit Arondekar June 26th, 2010 @ 12:07 PM

    Task is a reserved word. Using it can have weird consequences. A list of reserved words -> http://wiki.rubyonrails.org/rails/pages/reservedwords (Although the list is quite old).

  • Rohit Arondekar

    Rohit Arondekar June 26th, 2010 @ 12:14 PM

    • State changed from “new” to “invalid”

    Quoting http://wiki.rubyonrails.org/rails/pages/reservedwords

    The errors that occur when you use a reserved word tend to be very confusing. Things that you think are happening in your code, are actually happening somewhere in the framework. Sometimes you can look at the stack trace and see that its not going through your class, but through some framework class. If you have an error that makes no sense at all, I would check to make sure you don’t have a name that conflicts with the above list.

    I'm going to close this ticket, but if anybody still feels this needs to be patched or the issue is something else just make a comment and I'll reopen.

  • Ryan Bigg

    Ryan Bigg October 9th, 2010 @ 10:09 PM

    • Tag cleared.

    Automatic cleanup of spam.

  • Ryan Bigg

    Ryan Bigg October 11th, 2010 @ 10:58 AM

    Automatic cleanup of spam.

  • bingbing

Create your profile

Help contribute to this project by taking a few moments to create your personal profile. Create your profile »

<h2 style="font-size: 14px">Tickets have moved to Github</h2>

The new ticket tracker is available at <a href="https://github.com/rails/rails/issues">https://github.com/rails/rails/issues</a>

Pages