start new:
tmux
start new with session name:
tmux new -s myname
| gem install nokogiri -- --with-xml2-include=/usr/include/libxml2/libxml \ | |
| --with-xml2-lib=/usr/lib64/ \ | |
| --with-sxlt-include=/usr/include/libxslt \ | |
| --with-xslt-lib=/usr/lib64/ |
| function gcst(){ | |
| # $1: repo path | |
| # $2: tag-name | |
| git clone $1 | |
| cd ${$1%%.*} | |
| git tag -l | |
| git checkout $2 | |
| git branch -D master | |
| git checkout -b master |
| desc 'Pretty version on rails rake routes.' | |
| # modified from https://github.com/nicooga/color_routes | |
| # put this file under your [rails.root]/lib/tasks/ | |
| # tested under rails 4.0.0 | |
| # Default usage: | |
| # $>>> rake color_routes | |
| # Routes with specific controller | |
| # $>>> rake color_routes controller=devise/sessions | |
| # Routes with multiple filters | |
| # $>>> rake color_routes path=login verb=GET |
| # install something | |
| sudo apt-get install postgresql postgresql-contrib | |
| # check login ability | |
| sudo -u postgres psql | |
| # create user with passwords in shell | |
| sudo -u postgres createuser $UserName -P | |
| # try login as the created user |
The normal controller/view flow is to display a view template corresponding to the current controller action, but sometimes we want to change that. We use render in a controller when we want to respond within the current request, and redirect_to when we want to spawn a new request.
The render method is very overloaded in Rails. Most developers encounter it within the view template, using render :partial => 'form' or render @post.comments, but here we'll focus on usage within the controller.
| class Ability | |
| include CanCan::Ability | |
| def initialize(user) | |
| user ||= User.new # This is used for not logged user if you have a need for it | |
| if User.current_role == 'admin' # From ApplicationController we can get current_role and check it up against the role we want. | |
| can :manage, :all | |
| else |
| # Guide | |
| # Configure the essential configurations below and do the following: | |
| # | |
| # Repository Creation: | |
| # cap deploy:repository:create | |
| # git add . | |
| # git commit -am "initial commit" | |
| # git push origin master | |
| # | |
| # Initial Deployment: |
| #Session controller provides a token | |
| #/controllers/api/sessions_controller.rb | |
| class Api::SessionsController < Devise::SessionsController | |
| before_filter :authenticate_user!, :except => [:create] | |
| before_filter :ensure_params_exist, :except => [:destroy] | |
| respond_to :json | |
| def create | |
| resource = User.find_for_database_authentication(:email => params[:user_login][:email]) | |
| return invalid_login_attempt unless resource |