Archive for April, 2008

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.

Changes

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.

1
include Smerf

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

Old:

1
SmerfForm.smerf_user_id = ...

New:

1
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.