Skip to content

Instantly share code, notes, and snippets.

@covard
Last active October 16, 2019 21:53
Show Gist options
  • Save covard/5871583 to your computer and use it in GitHub Desktop.
Save covard/5871583 to your computer and use it in GitHub Desktop.
Using ActiveRecord (> 4.0) outside of Rails. Since you can't use attar_accessible anymore you have to do it like this.
# when using ActiveDirectory outside of rails need to do it like this for ActiveRecord 4.0
require 'action_controller'
raw_parameters = { :email => "[email protected]", :name => "John", :admin => true }
parameters = ActionController::Parameters.new(raw_parameters)
user = User.create(parameters.permit(:name, :email))
# Happy Rubying =)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment