Showing posts with label error. Show all posts
Showing posts with label error. Show all posts

Tuesday, February 3, 2009

Using --trace; cucumber & machinist order of loading files

I followed this tutorial to easily use Cucumber with a fixture replacement plugin called Machinist. It worked great on my desktop, but when I moved to my laptop, running rake features didn't work - an "uninitialized constant Sham" error popped up and I spent a day figuring it out.

Although the context of this problem is Cucumber and Machinist (which includes Sham), this is a post that talks about using --trace when you run into problems similar to this.

IF YOU'RE FAMILIAR WITH CUCUMBER & MACHINIST...
The problem occured partially because I put my blueprints.rb file where env.rb is. I believe cucumber loads everything there in alphabetical order (doesn't explain why my desktop loaded things differently). The problem is that blueprints.rb tries to call "Sham" which is something that is loaded by Machinist, which in turn is loaded during or after env.rb, not before.

IF YOU'RE NOT FAMILIAR NEITHER CUCUMBER NOR MACHINIST...
The problem occured because of the order files were loaded. I do not know why files were loaded differently in my desktop vs the laptop, but what the heck -- I found the error by using --trace and actually read the big bad ugly code that rake conveniently hides from us.

http://pastie.org/379188

So the lesson is: actually read what --trace spits out! :)

Monday, March 3, 2008

Expected User, got User; forcing to reload plugins

I made my own plugin and started getting this error. This plugin is a variation of the acts_as_voteable plugin by Juixe. I did some searching around, I found this blog post that explains the fix.

Apparently, in development mode, there are issues when it comes to reloading plugins. Because the model "Vote" in my case, or "Comment" in the blog post's case, is defined inside the plugin, Rails doesn't see that it should load it again. Anyway, better to read that post for an explanation.

What I did to fix it was add this code at the end of the environment.rb file:
 # Array of plugins with Application model dependencies.
reloadable_plugins = ["acts_as_commentable"]

# Force these plugins to reload, avoiding stale object references.
reloadable_plugins.each do |plugin_name|
reloadable_path = RAILS_ROOT + "/vendor/plugins/#{plugin_name}/lib"
Dependencies.load_once_paths.delete(reloadable_path)
end
See the code.

Friday, February 8, 2008

Expected "model.rb" to define Model

I was getting this error:

ActionView::TemplateError (Expected /home/lucidph/public_html/rails/pbed/app/models/article_photo.rb to define ArticlePhoto) on line #5 of articles/gen_xml.xml.builder

A lot of people get this with ferret and some bug with it, but I didn't have ferret. The problem: I forgot to upload attachment_fu to the server!