1. How to specify the layout when render() in controllers
There is an option in render/3 method, source
In the below example, I did specify the layout, the layout will be located at @conn.assigns[:layout], so as :id
And then, within scope, add the pipeline via pipe_through. Here is an example.
scope"/",ImageQuickSharedopipe_through[:browser,:empty_layout]# Use the default browser stackget"/",PageController,:indexget"/image",ImageController,:showend
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.
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.
plugPlug.Static,at:"/",from::blog_phoenix,gzip:false,only:~w(avatars css fonts images js favicon.ico robots.txt)### Other no need configurationend
defexport_search_resultrequire'spreadsheet'require'stringio'Spreadsheet.client_encoding='UTF-8'book=Spreadsheet::Workbook.newsheet1=book.create_worksheet#YOUR DATA PROCESSOR HEREfile_name="abc.xls"spreadsheet=StringIO.newbook.writespreadsheetsend_data(spreadsheet.string,:filename=>file_name,:type=>"application/vnd.ms-excel")end
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.