Error while using Fetcher plugin to process incoming mail with Rails? - ruby-on-rails

I'm trying to get a basic example app running that processes email. Nothing fancy, just the barest of functionality at this point. I've installed Fetcher, configured the YAML, updated the :receiver, and created an IncomingMailHandler class.
When I go to start the FetcherDaemon, I get the following error.
/Library/Ruby/Gems/1.8/gems/activesupport-2.3.2/lib/active_support/dependencies.rb:105:in `const_missing': uninitialized constant MailerDaemonFetcherDaemon::IncomingMailHandler (NameError)
I'm using Rails 2.3.2, with the latest Fetcher plugin. The IncomingMailHandler class in my models dir looks like this:
class IncomingMailHandler < ActionMailer::Base
def receive(email)
logger.info("Got a mail about: #{mail.subject}")
end
end
Help!

Ok, so basically, I'm a dumbass. I was following instructions all over the damn web, except for the mostly cut and dry explanation on github. Days later now, I just went through the motions, and boom, it worked flawlessly.
So, to anyone that finds this with the same problem (whether you were trying to follow the WAY outdated instructions on the PeepCode tutorial, or found some tips on a blog), don't be a dumbass like me. The most up-to-date info is on github.
Thanks to anyone that looked at this!

My guess is you didnt set the MailFetcher
MailFetcher.mailer_class = :incoming_mail_handler
put this in environment.rb after the RailsInitializer block.
If you want to use POP3 instead of IMAP you have to specify this there as well

Related

Cane with Rails

I just discovered the Cane gem but it doesn't work with Rails, there is a way to make it work with Rails?
Update
I'm using rails 3.2.1 and It doesn't produce any error message
I'm the author of this gem.
How do you mean "doesn't work"? It's possible you just write good code :) The default options aren't too strict. Can you please post the output of:
cane --style-glob '**/*.rb' --style-measure 1
This should error on every line in the project, to verify whether cane is "working". And also
find . app
When run from within your rails directory.

Ruby on Rails Plugin: acts_as_taggable_on_steroids. Keep getting "method_missing" undefined local variable or method 'acts_as_taggble_on'

I am trying to implement a tagging system for my rails app. I employed the popular plugin acts_as_taggable_on_steroids, and followed the instruction on how to install it. I then included acts_as_taggable in the model that I would like to have tags on, but then when I try to start the server I keep getting the error method_missing': undefined local variable or methodacts_as_taggable' for # (NameError)
I look on google and the author suggested to try acts_as_taggable_on, but still this did not fix the problem. I am struggling on this problem for hours already, but still don't know where is the problem. Could anyone please shed some light?
Thank you very much for all the help!!
Did you try to require the lib ruby of act as taggable on steroids at the beginning of your file?
Something like:
require 'acts_as_taggable'
maybe?

Starting out with vote_fu

Trying my luck with the vote_fu rails plugin. The functionality looks like exactly what I need for a project of mine, but I have hit a roadblock. I have followed the github readme to the letter, installing it as a plugin.
I have put acts_as_voteable on my "Event" model and acts_as_voter on my User model.
In the console, when I try:
>> event.votes
or
>> user.votes
it successfully returns an empty array.
but when I try to do the following:
user.vote_for(event)
I get
"NoMethodError: undefined method `user_id' for #<Vote:0x7f5ed4355540>"
Any ideas? I'm probably just missing something obvious, but maybe something is missing from the plugin's readme.
Thanks.
[Update]
I created a blank application and the plugin works fine, so I think that this problem might be being caused by the use of the "desert" plugin, as my User class is split over two files. If I find the answer, I'll post it so that in the off chance someone else runs into this it may be some help.
Cheers.
Ok, I haven't found a definitive reason why this problem occurred, but I do have strong suspicions that it is due to the use of the "desert" plugin, as my User class is split over two files (the project is using the CommunityEngine plugin as a base),
Anyhow, I found a work around (something I should have tried before posting here). Instead of installing vote_fu as a plugin, I installed it as a gem. And now vote_fu seems to be humming along nicely.
So let that be a lesson to you all!
:-P

How to use acts-as-commentable-with-threading in Rails

I am developing my first rails site (yup, i am a rails idiot).
I'm writing a blog, and i got to the comments part.
I installed acts-as-commentable-with-threading ( GitHub ), i made and ran the migration like the install instructions said.
I have added acts_as_commentable to my Posts model and i have a Comments controller
When i add
#comment = Comment.build_from(params[:id],1, params[:body] )
I get the error.
undefined method `build_from' for #
Clearly i am doing something terribly wrong, and i don't really get the example. What should i be feeding to build_from? Can somebody explain this plugin step by step? :)
Or is there an easier way to get simple threaded comments?
Did you by chance define your own comment model? If so that is going to completely override the model from the plugin that defines build_from in the first place. I ended up getting around this by creating a module with the extra stuff I wanted then creating an initializer to include it, which works perfectly.
As an aside, the first parameter to build_from needs to be the actual commentable object the comment is to be connected to, not just an id.
I'm currently using this plugin in production and can assure you it works :)
Besides the reason of not restarting server (btw you shouldn't use nginx + passenger for development, simple mongrel or thin will do the job better in this case) I can think of two more:
You didn't install plugin (or something wrong happened during installing). However this is unlikely as you could run migration ok right?
You have comment model in app/models and rails doesn't load it from plugin. In this case you might want to try requiring file with plain old require.

has_many_polymorphs tagging - works on development machine, not on production!

I'm having a weird problem, where tagging works fine on my development machine, but when I deploy to the production server, I get this error in the log:
ActionView::TemplateError (undefined method `tags' for #<Person:0x98bb9d4>) on line...
There is an entry in the production.log file that states that has_many_polymorphs is loaded, so it's not like the plugin isn't available on the production machine.
My Google-fu has failed me trying to find the answer, so if anyone knows what could be wrong it would be greatly appreciated!
Edit: I should have mentioned that on both production and development I'm using the same database. I downloaded the production one, and used it on the development machine and it works fine.
cap deploy:migrations
I've seen similar problems to this in which the polymorphic type field is not getting correctly filled in, or when there was some existing data prior to the polymorphic type tag getting added. Is person a subclass? does the _type field contain any null values on the polymorphs table?
Just stabbing in the dark here, but has_many_polymorphs doesn't natively add tagging functionality to your models. Instead, you use a generator to create a tagging extensions module that goes into lib/tagging_extensions.rb. The module file has helper methods that add tagging functions, built on top of the has_many_polymorphs base functionality.
So, is it possible that you have the plug-in installed, but not the tagging extensions file?
I spent some time with a consultant tracking this down, and eventually we discovered that for reasons unknown, the Tagging stuff just wasn't being loaded.
By adding a single line of code, just three letters, to the end of environment.rb, it was resolved. I commented it so that we'd never forget wtf was going on:
# Magic begins here.
# We need to force Rails to load the Tag record, or
# has_many_polymorphs doesn't work properly. I don't know
# if there's a better fix, but this one seems reasonable. :-/
Tag
That was it. I'm sure there's an elegant and proper solution to this, but this works. Weird.
I hope this helps someone out there.

Resources