Devise, generate hash password
The question is that you are using devise and you want to get hash password from raw password. Here is your solution:
The question is that you are using devise and you want to get hash password from raw password. Here is your solution:
This post is all about how to change redirect url after devise update password (or any?). By default, devise after change password successfully, it will redirect to the root url. There are step you have to do to change the redirect path.
Make devise controllers Or generate using command rails g
devise:controllers user
After generating, because I want to change the redirect url after changing
password. The only file I concern is passwords_controller.rb
, the method you
have to override is after_resetting_password_path_for
, within this method, you
have to declare your favorite redirect url.
for example:
This is a solution to configure the view path of any controller in Rails web
framework. The only method you have to concern is self.controller_path
With this configuration, all view of User::HomeController
will be located in app/users/home/
In Phoenix web framework, there is a share directory /priv
. By default, it
will only public css,js,images,fonts
directory. However, If you want to share
a new directory to save upload image for example, you have to end_point file at
/lib/app_name/end_point.ex . Look at plug Plug.Static
, the only:
macro
declares which directory, files could be public. Simply, you have to append your
directory name at only:
line.
This is my configuration to add a directory named avatar public. This directory
is under /priv/static
.
Your tree should look like below
On the front-end, instead of using Ajax(post, get). I uses window.location
On the back-end, I uses a gem named spreadsheet
1. Tuples It’s an order collection of values. There is a tip for using Tuples, a typical tuples has two to four elements
Map
2. List (LinkList) The list of Elixir is link-list, there are some features/specification that you should noted.
a[22]
. You will have to loop via 21 elements.3. Keyword List Keyword list is a list of tuples of pair values. An example below explain the keyword list.
4. Map Map is used to save collection with a pair of key and value. Unlike keyword list, Map does not allow duplicated keys. Accessing a map by:
I have work with spreadsheet gem on ruby, Sometime I do realize that in the
LibreOffice, the content is something like '24%
, the character single quote
refers to a string. However, I want a number instead. A possible way to convert
them without programming is Find and Replace. However it does not easy as I
say because the character '
is a special character in LibreOffice, you have to
use regular expression to work with this.
There is a solution to convert string to number in such case is using replace
function name Find and Replace C-h
in LibreOffice. In the Search for
text,
type ^.
; in the Replace with
, type $
. In the other options, please tick on
Regular expressions
. Finally, you can choose replace or replace all.
This is cheatsheet for Elixir, it’s a not a summary of this language, this article all about tweak, remember note for Elixir language.
1. For loop Given that, we we a list of map
Elixir supports a for conditional loop.
2. Update a map
3. Struct Generate Struct
Use Struct attribute
Update attr in a struct
Given that, you have to work with many decimal number for example: 0.335, 0.345,
0.2, 96.6666. And then you want to round those number 2 digits after decimal.
The most general way is to used toFix()
. However, the behavior of toFix()
is
not good. Let test with value 0.335
and 0.345
.
The better solution is that, we try to use the first two digit after decimal, the only issue is that, these two digit up/down are depend on the third digit, perhaps the fifth one. Number 44 is to solve this issue. Any number x.a-b-c-d
which has c-d
>= 56, the b
will be round up by one.
A good solution come up with a compact function which can help you use in any time.
Rails does support built-in CRUD with RESTful. It provides default url for developers. However, there could be a time that developer want to add more method/action to work with exist routes. Hence, this is solution.
This is a default setting for resources of pictures
This is modification with new upload method which use GET protocol.