4 months ago
Mass Assignment Protection, DataMapper, and Sinatra
Tip: You can use the DM Rails adapter MassAggisnmentSecurity sub-module inside Sinatra if you’d rather limit attribute access at the model level, rather than handling it in the controller (which certainly feels cleaner to me).
For example:
require 'dm-rails/mass_assignment_security'
class Status
include DataMapper::Resource
include DataMapper::MassAssignmentSecurity
attr_accessible :account_id, :contents, :source
end
You’ll, of cours,e need to install the dm-rails gem.
Edit: Just a not eI discovered after updating my gems yesterday. You cannot have two versions of Rack installed when using the Rails gem inside Sinatra. Rails will load Rack 1.4 first, and cause Sinatra to be unable to load Rack 1.3.5.
All Notes
-
kellishaver posted this