SMERF GUI Form Designer

I’m toying with the idea of developing a GUI form designer for SMERF. Initially the GUI would load and create the YAML form definition files so there would be no need for someone to manually code the YAML files.

I would like to get your feedback to see if this is really needed and if I did create it that people would actually use it. I would also like to get ideas on what people would like to see, so if you have any ideas please let me know.

My current thinking is that I would use Adobe Flex for the GUI with RESTFul Rails as the backend all packages as a Rails engine.

Looking forward to hearing your thoughts.

Maintenance Release

The following changes have been made:

  • Bug fix: As per the bug reported by bgoodwin. SMERF now correctly handles numeric question codes. Previously if a numeric question code was used the validation functions did not work correctly as it was trying to access the responses hash extracted directly from the HTTP request using a numeric key when all the keys in the responses hash are strings. SMERF will now convert numeric codes to a string before saving to the DB.
  • When dealing with subquestions of type singlechoice it was not possible for the user to clear previously selected answers if they decided to select a non-subquestion answer. SMERF will now check to see if a non-subquestion answer was selected and if the subquestion type is singlechoice it will clear the answers of the subquestion. Additionally it will display an error message to inform the user of the ambiguous answer, here is an example error message: Are you aged over 40: Ambiguous answer provided for question ‘Specify your ages’, the answers to this question has been cleared. Thanks to Michael Franzl for reporting this problem.

You can download the changes from GitHub. Touch or change all your SMERF form definition files to force SMERF to re-process them.

SMERF has moved to GitHub

The SMERF respository has now been moved to GitHub, so to get the latest version go here. Please note: updates will no longer be available from RubyForge.

You can easily install the plugin from GitHub by doing something like this, assuming I’m in the root directory of my Rails app: 

git clone git:// vendor/plugins/smerf

Maintenance Release Version 0.1.1

This update allows SMERF to be used with Rails 2.2 and the following changes have been made:

  • It appears that making changes directly to the view_paths array has been deprecated in Rails 2.1 onward and #append_view_path or prepend_view_path should be used instead. Template for smerf_init.rb changed to use append_view_path.
  • Dependencies is deprecated from Rails 2.2 onward and ActiveSupport::Dependencies should be used instead. Template for smerf_init.rb changed to use ActiveSupport::Dependencies.

I’ve also added the ability for the generator to skip migrations by adding the –skip-migration option. To re-run the generator without creating the migration you can do something like this:    

./script/generate smerf user --skip-migration

Rails 2.1 Unprocessed view path found error

There have been a couple of people using Rails 2.1 and above that have reported the following error:

Status: 500 Internal Server Error

  Unprocessed view path found: "…/vendor/plugins/smerf/app/views". Set your view paths with #append_view_path, #prepend_view_path, or #view_paths=

It appears that making changes directly to the view_paths array has been deprecated and #append_view_path or #prepend_view_path should be used instead. I will shortly release a new version to address this problem but in the mean time you can fix this problem by modifying the smerf_init.rb file in /vendor/plugins/smerf:

ActionController::Base.view_paths << file_path if file_path.include?(’views’)


ActionController::Base.append_view_path file_path if file_path.include?(’views’)

Major Update Version V0.1.0

I am pleased to announce a major update to SMERF to V0.1.0, there has been some significant code changes to overcome a number of problems. I would recommend that everyone upgrade to the new version as soon as possible.


Most of the problems relate to the use of class variables in the old version, the code has been completely rewritten to remove ALL class variables. The two main issues caused by the use of the class variables where:

  • The validations used for a form would be determined by the form that was loaded first, these validations would be used for all subsequent forms as the validations for the form was stored in a class variable and never replaced. This is only a problem if you have more than one form defined. Thanks to Alexander Lang for reporting this problem.
  • If you have more than one user accessing the system at the same time the results will be stored against the user that last logged into the system. Again this was caused by the id of the user record being stored in a class variable. Thanks to Christopher Souvey for reporting this problem.

Other changes in this release include:

  • Modify generator to convert model name to lowercase
  • Fix minor bug in smerf_forms_user template, additional ’s’ was being added to a variable name 
  • Include smerf_responses.rb in generated files as content on file depends on specified user model

How to Upgrade

Follow the following steps to upgrade an existing installation:

1. * Backup your current files

2. Generate SMERF again using:

ruby script/generate smerf usermodelname

You may need to delete the db migration file for it to run. There has been no DB changes so there is no need to do a migration.

3. Include the Smerf module in the controller where you are accessing smerf_user_id, if you want it to be available to all controllers include the module in application.rb, i.e.

include Smerf

4. You will need to change the code that you use to assign the user record id to SMERF:


SmerfForm.smerf_user_id = ...


self.smerf_user_id = ...

4. Touch or change all your SMERF form definition files to force SMERF to re-process them.

5. Test to make sure everything is working as expected.

Please Note:

  1. I have only tested this with Rails V2.0
  2. I have not yet written any tests for the plugin so please report any problems you experience.
  3. Use at your own risk.  

Maintenance Release Version 0.0.4

Thanks to Alan Masterson for finding and reporting a bug in the way responses where being handled when using the new selectionbox question type field, release Version 0.0.4 addresses this bug.

To update your system you will need to:

  • Download and install the new version
  • Generate the plugin again as one of the template files have been updated. You will need to delete the migration file before doing this otherwise the generate will not work, the migration has not changed so you will not need to rerun it again.
  • Test your application to make sure everything still works as expected.

SMERF Version 0.0.3 Released


  • Add new selectionbox question type.
  • Add selectionbox_multiselect question option.
  • Update RDoc with new question type details.

I’ve added a new question type using the select field type as requested by Alan Masterson. You can check out the Usage page for more details. You can use this new type by setting the question type to selectionbox. This will display all your answers as a drop down list of options from which the user can select a single answer.

Single choice select

A new field selectionbox_multiplechoice can be set for a select type question that allows the user to select multiple answers. 

I’ve updated the testsmerf.yml file to include examples of the new question type. You can get this file from the vendor/plugins/smerf/generators/smerf/templates/smerf directory or you can run the smerf generator again for it to install the new version. You will need to delete the previous migration file for the generator to run.

Other changes

Allow installation via the Rails plugin installer for information check out the Download page, you can now install the plugin using

ruby script/plugin install

I’ve cleaned up the templates directory by removing all non-template files, this has allowed me to simplify the generator quite a bit.


First Release of SMERF

I am happy to announce the very first release of SMERF (Simple MEta Rails Form). SMERF is a Ruby on Rails plugin that allows you to very easily create dynamic forms using a form definition file. You can quickly and easily create surveys, questionnaires, data collection or any other type of form.

It saves the user responses to a DB table which the user can then retrieve and modify at any time. Responses to each question on a form is also recorded in the DB allowing you to perform analysis of the responses via SQL queries. Check out the About and Usage pages for more information. If you have any problems, questions or suggestions please feel free to contact me at smerf at cascadia dot com dot au.