I am defining a variable in my controller method. I want to render js if the size of the variable is zero.
My code is:
def department
@department = Department.all
end
I want or do something like this:
def department
@department = Department.all
if @department.count > 0
render :html => html-template-name
else
render :js => "alert('No department available');"
end
end
What should be the syntax of render html part?
Aucun commentaire:
Enregistrer un commentaire