Get states based country:
@states = State.joins("INNER JOIN countries c on c.id = states.country_id").where("c.id LIKE ?", params[:country_id])
Get states based country:
@states = State.joins("INNER JOIN countries c on c.id = states.country_id").where("c.id LIKE ?", params[:country_id])
gem 'aescrypt'
bundle
gem install aescrypt==================================
password save in encrypted formateAdd On model:
before_save :encrypt_password
def encrypt_password
encrypted_data = AESCrypt.encrypt(self.password, ENV['ENCRYPT_KEY'])
self.password = encrypted_data
end=============================================Encrypting
encrypted_data = AESCrypt.encrypt(message, password)
message = AESCrypt.decrypt(encrypted_data, password)
=============================================On Controllerexit_password = []account.account_passwords.last(3).map(&:password).each do |encrypted_data|
my_password = AESCrypt.decrypt(encrypted_data, ENV['ENCRYPT_KEY'])
if my_password == create_params[:new_password]
exit_password << encrypted_data
end
end
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<div id="ccnumber">434343434</div>
<script type="text/javascript">
$('#ccnumber').text(function(_, val) {
return val.replace(/\d(?=\d{4})/g, "X");
});
</script>
https://linuxize.com/post/how-to-install-mongodb-on-ubuntu-18-04/
1. sudo apt-get install nano
2. sudo mkdir /etc/init
Then create file
3. sudo nano /etc/init/mongod.conf
https://askubuntu.com/questions/856073/mongod-unrecognized-service-mongod-service-is-present-already
4. sudo mongod --fork -f /etc/mongod.conf
5. mongo
ADD select2 gem in you gem file
https://github.com/platanus/activeadmin_addons/blob/master/docs/select2_search.md
input form:
f.input :category_id, as: :search_select, url: admin_categories_path, fields: [:name, :description], display_name: 'name', minimum_input_length: 2, order_by: 'description_asc'
ORf.inputs do
f.input :account_id, as: :search_select, url: admin_users_path,
fields: [:first_name], display_name: 'first_name', minimum_input_length: 2,
order_by: 'id'
end
ON FILTER: filter :category_id, as: :search_select_filter, url: proc { admin_categories_path },
fields: [:name, :description], display_name: 'name', minimum_input_length: 2,
order_by: 'description_asc'
Note Add new column `photo_or_video` in your MODEL
In Controller:
Check type: content_type(image or video)
file = img.original_filename
attachment_type = file.split(".").last
video_or_image = attachment_type.downcase
------------------------------------------
if video_or_image == "png" || video_or_image == "PNG" || video_or_image == "jpg" || video_or_image == "JPG" || video_or_image == "jpeg" || video_or_image == "JPEG" || video_or_image == "gif" || video_or_image == "GIF"
video_or_image = "image"
elsif video_or_image == "mp4" || video_or_image == "MP4" || video_or_image == "ogv" || video_or_image == "OGV" || video_or_image == "ogg" || video_or_image == "OGG" || video_or_image == "mov" || video_or_image == "MOV"
video_or_image = "video"
end
-------------------------------------------
And: User.create(attachment: img, photo_or_video: video_or_image)
==========================================================
gem 'mini_magick'
gem 'carrierwave'
gem 'carrierwave-video-thumbnailer'
Than
bundle
Install packages: sudo apt install ffmpegthumbnailer
===================================================
https://railsblogs.rohityadav.in/2017/11/uploading-any-media-file-with-carrier.html