Archive for the 'plugin' Category
Automatic Markup Validation
It is quite easy to extend your Ruby on Rails test infrastructure so every document is checked for validity.
- Install the plugin assert_valid_markup.
- Install my test_validation_helper.rb in your test directory.
- Require the validation helper from your test/test_helper.rb:
require File.expand_path(File.dirname(__FILE__) + "/test/test_validation_helper.rb")
After those three simple steps, your HTML and RSS documents are now being validated each time you run tests.
I am giving a brief presentation on this topic at the April 10, 2007 Boston Ruby Group meeting.
You can flip through a PDF of my slides if you would like more details.
Update: In addition to the PDF, my presentation is now hosted on slideshare and shown below. If you are reading this post in an aggregrator, you will need to click through for the show (or just use the PDF version).
2 comments
acts_as_favorite
We are using Josh Martin’s acts_as_favorite plugin (also here).
I have made a few acts_as_favorite bug fixes (contextual diff file). These properly set the user_id in your favorites table and update the favorites associations as you add/delete favorites.
Here is how we tell the user class that it will have favorites:
class User < ActiveRecord::Base acts_as_favorite_user end
Here is how we tell a different model that it can be marked as a favorite:
class Thing < ActiveRecord::Base acts_as_favorite end
In our controller, we allow a user to mark a favorite thing. There is code elsewhere which makes sure that the user is logged in.
class ThingController < ApplicationController
def add_favorite
@thing = Thing.find(params[:id])
@user = User.find(session[:user_id])
@user.has_favorite(@thing)
redirect_to :action => ’show’, :id => @thing
end
def remove_favorite
@thing = Thing.find(params[:id])
@user = User.find(session[:user_id])
@user.has_no_favorite(@thing)
redirect_to :action => ’show’, :id => @thing
end
end
That’s all there is to it. You now have users who can mark objects as favorites.
Update: It appears that the official repository for acts_as_favorite is not reliable. I have archived my snapshot of acts_as_favorite. This version includes the patch listed above.
28 comments

