Software dev, tech, mind hacks and the occasional personal bit

Contact / Feedback Form Plugin for Mephisto

If you use Mephisto, a content management / blogging system written in Rails, you may well be interested in using this new plug-in. It provides a form that lets visitors to your site leave their contact details and send you messages or feedback via email.

Please check out information about using the contact form plugin with Mephisto Drax 0.8.

This plug-in was developed for the new ThoughtWorks Studios site. As I wrote it at and for work, it is copyright ThoughtWorks, 2007. However, ThoughtWorks, being generous souls, is happy for me to open source it under the Apache 2.0 licence, which pretty much means you have free reign to use it as you want.


  • Mephisto Edge (the latest stable 0.7.3 release does not have support for Mephisto plugins)
  • Rails Edge (required by Mephisto edge)
  • ActionMailer (comes with Rails) correctly configured with SMTP server etc, so that emails can be delivered. See “Configuration” section here for more details.


ruby script/plugin install

or in your vendor/plugins directory for Mephisto:

git clone mephisto_contact_form

Make sure you restart your web server at this point so that the plugin is loaded.

1. Create a new template called ‘contact_us.liquid’ though the admin web interface (under the ‘Design’ tab).
Paste in the following code:

<H1>Contact Us</H1>
{% contactform %}
<p>{{ }}<label for="author"><small>Your name</small></label></p>
<p>{{ }}<label for="email"><small>Email address</small></label></p>
<p>{{}}<label for="phone"><small>Phone number (optional)</small></label></p>
<p>{{ form.subject}}<label for="subject"><small>Subject</small></label></p>
<p>{{ form.body }}</p>
<p>{{ form.submit }}</p>
{% endcontactform %}

Feel free to modify labels, layout etc.

2. Edit


and put in the email address you want contact form submissions to go to.

3. Link to “/contact_form” from your site.

Any issues / questions / suggestions?
Best to post comments on this blog.

Technical Info
The contact form plugin is actually a combination of a rails plugin, a liquid block plugin and a Mephisto plugin. See this post about developing Mephisto plugins for more information.


Wing Chun: Bong Sau Tips


A few choice quotes from “The Unbearable Lightness Of Being” by Milan Kundera


  1. Anonymous

    Hi James,

    For #3 “Link to “/contact_form” from your site.”. How do you exactly go about doing that.

    Does that mean to add a new section from the admin panel and use the contact_us.liquid as the page template.

    Let me know if you could provide more specific instructions for this.


  2. James Crisp

    No need to add a new section in the admin panel. Once the plug-in is installed, it adds a route to /contact_form to Mephisto. Say you want to link to the contact form from a page, you would add a link like this:

    <a href=”/contact_form”>Contact Us</a>

  3. Anonymous

    Hello james

    thanks for your work on the contact form. it was exactly what I was looking for. Had to install a new trunk version of Mephisto to make it work – but in the final…

    P.S. Any idea how to use iframes in Rails? Is there a plugin somewhere out there in the Rails world? Or another solution?

  4. James Crisp

    Hi Michael,

    Thanks for your comment. Depending on your requirements, a better solution may be to use ajax and divs. See more info here:

  5. Brian

    Hi James,

    I’m using 0.7.3 🙁 is there a solution of some sort to actually make it work in v0.7.3?

    what could I do as an alternitive.?

    Thanks in advance


  6. James Crisp

    Hi Brian,

    I haven’t tried it, and there may be more gotchas, but if you install the plug-in and then add the routes manually to Mephisto’s routes.rb that are in here:

    it may well work 🙂

    Also, if you set up a test database, you should be able to run the unit tests and see if anything else is lacking/broken.

    Please post to tell me how it goes!


  7. Octave Z

    Hello! Thanks for your plugin. It work good. How can I add a layout for this page or if it’s not possible show the title of the page (ex: My Site | Contact).

    Thanks in advance.

  8. josh huckabee

    Hi James – great plugin!

    I added a very minor modification to allow the user to update the destination email address in the plugin configuration.

    The changes are listed here:

    Thanks again!

  9. Philip

    Thanks for a great contribution!

    Now my next question is how to get plugins to load on a shared hosting situation at RailsPlayground, where “restarting my Rails app” is not an option. Hmmm….

  10. James Crisp

    Hi Phillip,

    Assuming your hosting is apache fast cgi, you can kill any processes running under your user called dispatch.fcgi. That should be pretty much the same as a server restart.


  11. Philip

    Thanks, James.

    Unfortunately, I’m still having a horrific time getting it going under stable 0.7 of Mephisto (rev. 2852, last changed 2828) and Rails 1.2.2 on my shared Linux hosting. RailsPlayground reports the following when they run via Webrick:

    => Booting WEBrick…
    /usr/local/lib/ruby/gems/1.8/gems/activesupport-1.4.1/lib/active_support/dependencies.rb:266:in `load_missing_constant’: uninitialized constant Mephisto::Plugin (NameError)
    from /usr/local/lib/ruby/gems/1.8/gems/activesupport-1.4.1/lib/active_support/dependencies.rb:452:in `const_missing’
    from ./script/../config/../vendor/plugins/mephisto_contact_form/lib/plugin.rb:3
    from /usr/local/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:27:in `gem_original_require’
    from /usr/local/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:27:in `require’
    from /usr/local/lib/ruby/gems/1.8/gems/activesupport-1.4.1/lib/active_support/dependencies.rb:495:in `require’
    from /usr/local/lib/ruby/gems/1.8/gems/activesupport-1.4.1/lib/active_support/dependencies.rb:342:in `new_constants_in’
    from /usr/local/lib/ruby/gems/1.8/gems/activesupport-1.4.1/lib/active_support/dependencies.rb:495:in `require’
    from script/../config/../vendor/plugins/mephisto_contact_form/init.rb:12:in `load_plugin’
    … 21 levels…
    from /usr/local/lib/ruby/gems/1.8/gems/rails-1.2.2/lib/commands/server.rb:39
    from /usr/local/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:27:in `gem_original_require’
    from /usr/local/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:27:in `require’
    from script/server:3

    As it happens, I get exactly the same problem on my local Win XP installation, which at least makes troubleshooting easy. 🙂

    I seem to recall seeing this problem with another app, and it may have been the results of some change in the plugin system. I feel like I’m missing some step, as though my versions are mismatched or something. Any ideas?



  12. Philip

    Sorry, i can’t read. Is Mephisto Edge a reliable platform for one’s professional Web site? It certainly sounds like I’d be better off with a stable version, but then I’m going to have to attempt your hacking suggestions in the comment to Brian above.

    Should I ask Rick for a development roadmap so I can assess when I can get a stable version of Mephisto that supports this plugin? Or is such a roadmap published somewhere?

  13. James Crisp

    Hi Phillip,

    The last Mephisto release was almost a year ago.. I don’t know when the next one is due – probably best to ask Rick as you suggest, and also get his opinion on edge stability.


  14. Anonymous

    Hi James and thanks for your wonderful plugin,I was using it flawlessly on my mephisto trunk, now i setup a new mephisto install on mediatemple, do no tknwo why, but actually when i am trying to send emails after setting up all the things as specified i got an error page?????mmmm i checked my production.log and i’ve found a weird message (i am pasting here the main line from my log saving your time from reading all the rest, but i guess this is the main error)
    NoMethodError (undefined method `com’ for nil:NilClass):
    /vendor/plugins/mephisto_contact_form/lib/contact_notifier.rb:7:in `contact_notification’

    it seems something is wrong when i setup my recipients into contact notifier.

    Do not know what i am doing wrong actually i specified “[email protected]

    it seems that it doesn’t like the “.com” part of the thing:)

    Any help is highly appreciated and thanks again for your wonderful contribution

  15. Dylan

    Hey James,

    Great plugin. I’ve got everything working except I’m not receiving the email. My logs show the email that is sent and I’ve tried configuring it to use both smtp and sendmail.

    Have you got any tips for debugging ActionMailer and its configuration?



  16. sc0ttman

    Hey everyone. I was wondering if anyone knows a way to detect in my layout when I am on the contact form? I would like to know this in order to render a tab in my css as style=’selected’.
    Is there anyway to know this??

    {% if == “Contact” %} or something like this?

  17. Not sure why, but when I put this into to Mephisto edge on rails 1.99.1 it would return a 404 error on looking at localhost/contact_form.

    I dug around the console, it was showing up on the custom_routes as well as in the $LOAD_PATH… just wasn’t showing up in ActionController::Routing::Routes.routes

    Handling was to put the following into the config/routes.rb file to hard code the routes in and now it works fine.

    ActionController::Routing::Routes.draw do |map|

    Mephisto::Routing.connect_with map do "/contact_form",
    { :action=>"contact_form",
    :controller=>"contact_form" } "/contact_submit",
    { :conditions=>{:method=>:post},


    Hope that helps someone else.


  18. Thanks Mikel for finding this and sending me a patch. I’ve applied it tonight to the contact form repository.

    Something seems to have changed in either Edge Rails or Edge Mephisto that breaks the Mephisto plug-in API’s add_route method. The problem seems to be that Mephisto route configuration (lib/mephisto/routing.rb) is now happening before plug-ins are loaded. Previously, plug-ins were loaded before Mehisto route configuration was done. I’ll investigate further when I get a chance. Keen to hear ideas on a fix for add_route 🙂


  19. I’m on mephisto revision 3074 with rails 2.0.2 and the add_routes methods seem to be working. In fact, I had to use them instead of the routing patch. Just an FYI.

    Thanks for the plugin!

  20. James

    the email bodies are showing up in my rails application logs, causing a large amount of wasted space. Anybody know how to prevent this?

  21. Suggest increasing your logging level filtering in production. See:

  22. Mark, that’s good news and thanks for dropping me a line. I’ve updated the code back to using add_route.

  23. nic

    Man, I wish I could use this but I’m a rails noob and can’t figure out what is wrong. When I install it I get an application error. Nothing is written in my logs when this happens either. Am I doing something wrong?

  24. Hey Nic,

    Are you running with apache fcgi? Maybe this post might help:


  25. Roche Foo

    Hey James,

    Ths for the share, nice to see that the Plugin is easily extensible.

    When installing i didn’t see the version required while my mephisto is 0.7.2. Now i got a problem the same with Philip.

    How could i unistall the plugin now?


    Roche Foo

  26. Hi Roche,

    To uninstall any rails plug-in you should just be able to delete the directory:
    [RAILS ROOT]/vendor/plugins/[PLUGIN NAME]


  27. Roche Foo

    Ths a billion, it works.

  28. Pat Roy

    Hi, I’m running Rails 2.0.2 with Mephisto Drax 0.8 with the latest version of this plugin and I can’t get the /contact_form route to work. I’ve tried everything people recommend in the comments. No go. Anybody can help?

    I get this when manually add the routes:

    uninitialized constant ContactFormController

  29. Pat Roy

    Nevermind I didn’t have the right Mephisto version (without Engines). If you download mephisto from github the 0.8 tag won’t have Engines you have to download from the master branch.

  30. Glad you got it sorted, and thanks for posting your solution.

  31. If you get weird mail errors ie: “Net::SMTPSyntaxError (501 5.1.3 Bad recipient address syntax)” you may need to add this to your environments.rb: config.action_mailer.delivery_method = :sendmail Should work if you are using postfix or sendmail (postfix has a sendmail clone so you can swap it out easily)

  32. Real excellent info can be found on weblog .

Powered by WordPress & Theme by Anders Norén