This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
has_many :organizations, through: :user_roles do | |
def default | |
where(:default_organization_id => self.id).first | |
end | |
end |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// If you use Redux Thunk... | |
import { createStore, applyMiddleware } from 'redux' | |
import thunk from 'redux-thunk' | |
const store = createStore(reducer, applyMiddleware(thunk)) | |
// You can define asynchronous action creators that return functions. | |
// We call such action creators "thunks": | |
export function getUser(id) { | |
// Redux Thunk will inject dispatch here: |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* Single Key Filter */ | |
SELECT * FROM users | |
WHERE id IN (SELECT id | |
FROM (SELECT id, ROW_NUMBER() | |
OVER (PARTITION BY email ORDER BY id) AS rnum | |
FROM users) t | |
WHERE t.rnum > 1); | |
/* Multi Key Fileter */ | |
SELECT * FROM theme_files |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function objectPropertyTrace(object, path){ | |
let key = path.shift(); | |
let o = object[key]; | |
if(path.length === 0 || o === undefined || path[0] === ""){ | |
return o; | |
} else { | |
return objectPropertyTrace(o, path); | |
} | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Run In Console | |
rails g model Foo | |
rails g scaffold_controller Admin::Foo --model-name=Foo | |
# Generates | |
# db/migrate/20160907201951_create_foo.rb | |
# app/models/foo.rb | |
# app/controllers/admin/foo_controller.rb | |
# app/views/admin/foo | |
# app/views/admin/foo/index.html.erb |