Skip to content

Instantly share code, notes, and snippets.

View jasper502's full-sized avatar

Dan Tappin jasper502

View GitHub Profile
@jasper502
jasper502 / document_uploader.rb
Created April 22, 2016 06:34
conditional_carrierwave
# encoding: utf-8
class DocumentUploader < CarrierWave::Uploader::Base
# http://stackoverflow.com/questions/29624223/papertrail-doesnt-play-nice-with-carrierwave-and-remove-previously-stored-file
#configure do |config|
# config.remove_previously_stored_files_after_update = false
#end
@jasper502
jasper502 / new_matcher.js
Last active March 13, 2016 04:23
select2 modification
function matcher (params, data) {
// Always return the object if there is nothing to compare
if ($.trim(params.term) === '') {
return data;
}
// MOVE THIS UP SO IF THE GROUP HITS A MATCH IT DOES NO SEARCH THE CHILDREN
var original = stripDiacritics(data.text).toUpperCase();
var oldterm = stripDiacritics(params.term).toUpperCase();
// Check if the text contains the term
@jasper502
jasper502 / Gemfile.lock
Last active February 16, 2016 17:11
Active Admin + Apartment + Devise = Bad News
GIT
remote: git://github.com/activeadmin/activeadmin.git
revision: 4349a2237894aae45569c5a7d25488081ba2d32f
specs:
activeadmin (1.0.0.pre2)
arbre (~> 1.0, >= 1.0.2)
bourbon
coffee-rails
formtastic (~> 3.1)
formtastic_i18n
@jasper502
jasper502 / active_admin.rb
Last active January 15, 2024 06:00
Active Admin, Devise and Pundit
# /config/initializers/active_admin.rb
ActiveAdmin.setup do |config|
# == User Authentication
#
# Active Admin will automatically call an authentication
# method in a before filter of all controller actions to
# ensure that there is a currently logged in admin user.
#
# This setting changes the method which Active Admin calls
@jasper502
jasper502 / README
Last active December 30, 2022 18:07
Devise with additional user fields, nested models / attributes and custom routes
The idea here is that I have a single User login that can eventually be tied to multiple Companies via the Role.
You signup via Devise on the custom /register route and fillout the Company information etc. The custom registration controller creates the Role during the user creation and sets a few other attributes.
It all worked but now it's broken and I have no idea what I did to break it.
When I try to create a new user / company the additional user fields (name_first & name_last) always fail validation regardless if they are in fact valid. The nested Company fields do not validate at all. If I enter the email and password field only the form works but only creates the User record.
To me it seems like the custom registration controller is not being processed at all.