A (more) complete cheatsheet for Arel, including NamedFunction functions, raw SQL and window functions.
posts = Arel::Table.new(:posts)
posts = Post.arel_table # ActiveRecord| convert string in arrays | |
| add all elements of array | |
| find duplicate element in array | |
| get fibonacci series of any given number | |
| get factorial of any given number | |
| create a pyramid of star | |
| find remainder of a number | |
| create recursive function - get value and add new value to the output | |
| create a logic to check if number is a palindrome or not | |
| check max occurance of any chars in a string |
| module Authenticable | |
| # Devise methods overwrite | |
| def current_user | |
| @current_user ||= User.find_by(authentication_token: request.headers['Authorization']) | |
| end | |
| def authenticate_with_token! | |
| render json: { errors: "Not authenticated" }, | |
| status: :unauthorized unless user_signed_in? |
| var a={}, | |
| b={key:'b'}, | |
| c={key:'c'}; | |
| a[b]=123; | |
| a[c]=456; | |
| console.log(a[b]); | |
| console.log(a); | |
| Output: |
Run rails new --help to view all of the options you can pass to rails new:
$ bin/rails new --help
Usage:
rails new APP_PATH [options]
Options:
-r, [--ruby=PATH] # Path to the Ruby binary of your choice
# Default: /Users/eliot/.rbenv/versions/2.2.0/bin/ruby
https://github.com/ankane/searchkick
By default, simply adding the call 'searchkick' to a model will do an unclever indexing of all fields (but not has_many or belongs_to attributes).
In practice, you'll need to customize what gets indexed. This is done by defining a method on your model called search_data
def search_data