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
class Ability | |
include CanCan::Ability | |
def initialize(user) | |
#to ensure user object is not nil when no user object is passed in | |
user ||= User.new | |
can :manage, User, :id => user.id | |
#can :manage, User do |user| |
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
#thanks to Kevin Wang for posting http://hashrocket.com/blog/posts/bridging-activerecord-and-mongoid | |
#association_name creates an instance method | |
#singularize(word) returns the singular form of a word | |
#classify(table_name) creates a class name from a plural table name eg 'posts.classify' => 'Post' | |
#underscore(camel_cased_word) Makes an underscored, lowercase form from the expression in the string. | |
#eg of undrscore -'ActiveModel'.underscore # => "active_model" | |
#class_eval defines instance methods. | |
#class_eval evaluates a string/block in the context of the module or class. | |
#underscore(camel_cased_word) makes an underscore eg 'ActiveModel'.underscore => 'active_model' |
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
rails g scaffold course title:string start_day:date start_time:time cost:decimal approved:boolean picture:binary course_duration:integer | |
require 'test_helper' | |
class CoursesControllerTest < ActionController::TestCase | |
setup do | |
@course = courses(:one) | |
end | |
test "should get index" do |
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
# install using the line below in your terminal | |
# wget --no-check-certificate https://gist.githubusercontent.com/mankind/3926ea58d2172c260f21/raw/0b426c12c04f75dc78e51e0b556421070801ddae/rails_nodejs_install.sh && bash rails_nodejs_install.sh | |
echo "=======================================" | |
echo "========= updating Packages repo =========" | |
echo "=======================================" | |
sudo apt-get -y update && apt-get upgrade |
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
# install using the line below in your terminal | |
#wget --no-check-certificate https://gist.githubusercontent.com/mankind/f44f8232f5d23a774bae/raw/1f53948207b9ff97cf55954f26b2069096b4d82b/ruby_dependencies.sh && bash ruby_dependencies.sh | |
echo "=======================================" | |
echo "========= updating Packages repo =========" | |
echo "=======================================" | |
sudo apt-get -y update && apt-get upgrade |
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
#https://github.com/fesplugas/rbenv-installer/blob/master/bin/rbenv-installer | |
#wget --no-check-certificate https://gist.githubusercontent.com/mankind/de9ef556a579f3980dea/raw/301942dcfd869879d9b1f7224d4bb52d78813bec/rbenv_install.sh && bash rbenv_install.sh | |
sudo apt-get -y update && apt-get upgrade | |
echo "=======================================" | |
echo "========= Cloning Rbenv =========" | |
echo "=======================================" | |
# https://gorails.com/setup/ubuntu/13.10 |
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
class SessionsController < Devise::SessionsController | |
#fix Filter chain halted as :require_no_authentication | |
prepend_before_filter :require_no_authentication, :only => [ :new, :create, :cancel ] | |
#to tackle: Filter chain halted as :verify_signed_out_user | |
skip_before_filter :verify_signed_out_user, only: :destroy | |
# disable it for everything except a few methods | |
#skip_before_action :verify_authenticity_token, :only => :create |
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
// controllers/application.js | |
import Ember from 'ember'; | |
export default Ember.Controller.extend({ | |
currentUser: null, | |
authToken: '', | |
// used to show, or not show, the log out button | |
loggedIn: false, |
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
import Ember from 'ember'; | |
export default Ember.Route.extend({ | |
//a = Charity.__container__.lookup('controller:application') | |
//a.get('csrfService') | |
//a.get('csrfService').token.authenticity_token | |
//or | |
//a.csrfService | |
//a.csrfService.token.authenticity_token |
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
namespace :api do | |
#when devise_for is called in a namespace, the helpers and controller filters change | |
#:singular => :user added so we can use current_user instead of current_api_user. | |
#And before_filter authenticate_user! instead of authenticate_api_user! | |
#https://github.com/plataformatec/devise/issues/412 | |
#devise_for :users, :singular => :user, skip: :all | |
get :csrf, to: 'csrf#index' | |
resources :users |