I couldn't figure out how to pass an argument to a decorator from a controller:
The decorator:
def as_json(options = nil)
{
:name => user.name,
:dob => user.dob
:created_at => user.created_at,
:url => user
}
end
The controller:
format.json { render :json => UserJsonDecorator.new(@user)}
Just passing an extra argument to the new method does not work:
UserJsonDecorator.new(@user,options)
Any ideas?
I was basically using it wrong.
correct form to pass additional arguments is:
UserJsonDecorator.new(@user).to_json(options)