How do you make instance variable in a controller and use the instance
variable in the view?
I need to know if a directory is empty so as they will not be displayed.
Trying to store: If a directory has files; Then I will call it in the view.
def index
@filter = params[:filter]
@type = params[:type]
@content = []
if @filter
directory_path = "public/files/marketing/voip"
directory = Dir.glob("#{directory_path}/#{@filter}/#{@type}")
directory.each do |data|
if File.exists?(data) && !File.directory?(data)
@content = Array.new("#{@type}")
end
@view = 'types'
end
end
I am not sure how to store the information, here I want to store the @type
of only empty directories.
Then call @content in the view to display the directories that have the
@type I stored.
No comments:
Post a Comment