Created
November 18, 2017 01:49
-
-
Save stuartambient/d04fc61c5747918541da1f37beda25f9 to your computer and use it in GitHub Desktop.
Inserting the album_sub_folder id conditional statement
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# is it possible to have an if statement in the insert | |
# dataset and map works in bin/sequel so that is not the problem | |
check_ids = DB.fetch("SELECT * FROM album_sub_folders WHERE album_id = {@album_id}") | |
..... | |
..... | |
MUSIC_FILES.insert(file_name: File.basename(entry), | |
album_id: @album_id, | |
album_sub_folder_id: @asf_id if check_ids.map.count > 0, | |
mf_path: File.expand_path(entry), | |
size: File.new(entry).size, | |
created_on: File.ctime(entry), | |
modified_on: File.mtime(entry), | |
file_extension: File.extname(entry)) if File.file?(File.absolute_path(entry)) | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment