Rake test suddenly stopped working - ruby-on-rails

I have been working with my rails application and since today I have not been able to run rake test:units
I though maybe my Ruby installation is broken or something, so I tried creating a new application, created a new model quickly, wrote a couple of unit test and then ran them. Everything seems to be running fine with the new app.
Please check the error log generated here http://pastebin.com/jgNXpXE3

Seems there's a bug in your Product model. Do you have a call to validates without any parameters passed to it?
http://api.rubyonrails.org/classes/ActiveModel/Validations/ClassMethods.html#method-i-validates

Related

Error Installing importmap on rails application

I am having troubling setting up an existing rails application. I am supposed to set up importmap but it is giving me trouble.
If having trouble viewing the uploaded pic, it says "rails aborted!
Don't know how to build task 'importmap:install'"
Rails error pic
If I run "rails --tasks" importmap:install does show up.
rails --tasks output snippet
As per the attached screenshot of the task list, the actual task name apparently is called app:importmap:install instead of importmap:install.
I'm not sure why that might be the case, though. It seems to me like you might (accidentally?) be working on a Rails engine instead of an actual app?

ruby on rails unable to find interface that appears to be proplery defined

I'm brand new to ruby on rails and trying to run an application developed by others. I downloaded it from SVN it running yesterday, but today when I try to run it the first attempt to access the site's home page I get the message:
expected .../app/helpers/interface/table_helper.rb to define Interface::tableHelper.
.../lib/active_support/dependencies.rb:452:in 'load_missing_constant'
This file exists, and properly defines the tableHelper interface. Since I was able to run the program when I was setting it up yesterday, and others can run it without issue, I assume the problem I'm seeing is caused by an incorrectly set up environment rather then bad code somehow.
Can anyone suggest what I might try to figure out why rails can't seem to detect a properly defined interface?
If you were able to run the program once, perhaps something got screwed up? Have you made any changes to the code?
Alternatively, try stopping and restarting the server.
Also: what's the application? Maybe we can look at the codebase...

Rails moving from 2.2.2 to 2.3.8 - rake not loading the environment same as the console or my app

I have an app that has been around a while that I'm migrating for
Rails 2.3.8. There have been a lot of interesting issues, but I'm on
the home stretch, but have now run into some very odd errors.
The gist is when I run a task with rake it fails, but when I run the
same code form the console it works fine. The 'fix' I devised was to
move my include ModuleNameA, include ModuleNameB, etc to the bottom of
the AR file.
I don't like this 'fix' as I don't understand it. Before I moved them
the AR object (we will call it Bob) kept throwing undefined method
errors when it was called through the rake invocation. It was invoked
in the rake task, but in another AR object.
So the rake task was running something like Worker.work, and it would
fail as described above. When I run Worker.work from the console it
would pass. Once I moved the includes to the bottom of the file both
would work.
Anyone ever seen anything like this? I feel like something
fundamental isn't correct. Like I have broken something basic to the
functionality and my 'fix' is some kind of weird patch.
thanks.
Erik
PS:
There is a module that I'm including in my AR object. It adds class and instance methods by doing:
def self.included(base)
base.extend(ClassMethods)
end
All of the methods in this module are available in the console, but not through rake tasks.
Update:
I noticed that if i take the :work => :environment part out of the
rake task and instead in the task do block require the environment
file by hand (e.g. require(File.join(RAILS_ROOT, 'config',
'environment'))) it works fine. All of a sudden all of my class
methods are available. this is very disturbing.
So I figured it out....
We had a directory under app/models called deals that was not included in the load path. That is where my module was that was giving me all the issues. Why it was being loaded OK from the console and not with rake...I don't know.
Once I added this to the config.load_path everything has started working fine. I never noticed this because in 2.2.2 everything worked fine, the app in production or dev mode, the console and the rake tasks in dev, test, and production mode.
I figured it was something just basic i was doing wrong as the error was obtuse and my 'fixes' looked like really bad ideas.

Rails NoMethod Error when calling a dynamic attribute find

I am currently working on an app. In this app, I created a Person model and I was using rail's dynamic attribute find feature. In the Person model I have an attribute called uid, so I was calling Person.find_by_uid(some numerical value). This worked fine in my development mode and the app was totally functioning. However, once I deployed this app to heroku. The app failed and the log complains about NoMethodError (undefined method `find_by_uid' for #):
I have been looking all places, but still unable to track down the problem. I tried to define the method find_by_uid under the Person model, and still does not work.
I was wondering if anyone has had similar experience or knows how to solve this issue?
Thank you very much ahead of the time!
Did you try running the migrations in heroku (heroku rake db:migrate)? Most provably that attribute is not in the heroku data base so you don't have that dynamic method.
I ran into the same problem. heroku restart has saved me.

Rails Tests Fail With Sqlite3

I seem to be getting a strange error when I run my tests in rails, they are all failing for the same reason and none of the online documentation seems particularly helpful in regards to this particular error:
SQLite3::SQLException: cannot rollback - no transaction is active
This error is crippling my ability to test my application and seems to have appeared suddenly. I have the latest version of sqlite3 (3.6.2), the latest sqlite3-ruby (1.2.4) gem and the latest rails (2.1.1).
Check http://dev.rubyonrails.org/ticket/4403 which shows a workaround. Could that be the problem you are encountering?
I had this problem once but with MySQL. Turned out I hadn't created the test database. Doh! Rails and sqlite creates them automatically I believe (at least it does in windows).
Are trying to do in memory testing? If not does the test database exist?
I got this error when running a test with the last statement being a click on a form submit. Once I did an assertion or should test, the test closed properly, and I didn't have to rerun the rake db:test:prepare
Thanks for the help. I actually ended up just deleting the rails folder and checking back out the last working copy from version control. I've made the identical changes and this problem hasn't reappeared, so either I messed up or rails had some sort of hiccup. Thankfully I had version control :-)

Resources